Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Walter Felipe
submeta
Commits
31c22774
Commit
31c22774
authored
May 26, 2020
by
carlos
Browse files
crud subarea
parent
19de8764
Changes
10
Show whitespace changes
Inline
Side-by-side
app/Http/Controllers/AreaController.php
View file @
31c22774
...
...
@@ -20,7 +20,8 @@ class AreaController extends Controller
*/
public
function
index
()
{
//
$areas
=
Area
::
orderBy
(
'nome'
)
->
get
();
return
view
(
'naturezas.area.index'
)
->
with
([
'areas'
=>
$areas
]);
}
/**
...
...
app/Http/Controllers/SubAreaController.php
0 → 100644
View file @
31c22774
<?php
namespace
App\Http\Controllers
;
use
Illuminate\Http\Request
;
use
App\Area
;
use
App\SubArea
;
class
SubAreaController
extends
Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public
function
index
()
{
$subAreas
=
SubArea
::
orderBy
(
'nome'
)
->
get
();
return
view
(
'naturezas.subArea.index'
)
->
with
([
'subAreas'
=>
$subAreas
]);
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public
function
create
(
$areaId
)
{
return
view
(
'naturezas.subArea.nova_subarea'
)
->
with
([
'areaId'
=>
$areaId
]);
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public
function
store
(
Request
$request
,
$id
)
{
$validated
=
$request
->
validate
([
'nome'
=>
'required'
,
]);
$subarea
=
new
SubArea
();
$subarea
->
nome
=
$request
->
nome
;
$subarea
->
area_id
=
$id
;
$subarea
->
save
();
return
redirect
(
route
(
'area.show'
,
[
'id'
=>
$id
])
)
->
with
([
'mensagem'
=>
'Subárea cadastrada com sucesso'
]);
}
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public
function
show
(
$id
)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public
function
edit
(
$id
)
{
$subarea
=
SubArea
::
find
(
$id
);
return
view
(
'naturezas.subArea.editar_subarea'
)
->
with
([
'subarea'
=>
$subarea
]);
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public
function
update
(
Request
$request
,
$id
)
{
$validated
=
$request
->
validate
([
'nome'
=>
'required'
,
]);
$subarea
=
SubArea
::
find
(
$id
);
$subarea
->
nome
=
$request
->
nome
;
$subarea
->
update
();
return
redirect
(
route
(
'area.show'
,
[
'id'
=>
$subarea
->
area_id
])
)
->
with
([
'mensagem'
=>
'Subárea atualizada com sucesso'
]);
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public
function
destroy
(
$id
)
{
$subarea
=
SubArea
::
find
(
$id
);
$areaId
=
$subarea
->
area_id
;
$subarea
->
delete
();
return
redirect
(
route
(
'area.show'
,
[
'id'
=>
$areaId
])
)
->
with
([
'mensagem'
=>
'Subárea deletada com sucesso'
]);
}
}
resources/views/naturezas/area/detalhes.blade.php
View file @
31c22774
...
...
@@ -15,7 +15,7 @@
<
h2
style
=
"margin-top: 100px; "
>
{{
__
(
'Subáreas de '
)
.
$area
->
nome
}}
</
h2
>
</
div
>
<
div
class
=
"col-sm-3"
>
<
a
href
=
"{{ route('area.criar', ['id' =>
$area->id
]) }}"
class
=
"btn btn-primary"
style
=
"position:relative;top:100px;"
>
{{
__
(
'Criar subárea'
)
}}
</
a
>
<
a
href
=
"{{ route('
sub
area.criar', ['id' =>
$area->id
]) }}"
class
=
"btn btn-primary"
style
=
"position:relative;top:100px;"
>
{{
__
(
'Criar subárea'
)
}}
</
a
>
</
div
>
</
div
>
...
...
@@ -38,11 +38,11 @@
<
a
id
=
"options"
class
=
"dropdown-toggle "
data
-
toggle
=
"dropdown"
aria
-
haspopup
=
"true"
aria
-
expanded
=
"false"
>
</
a
>
<
div
class
=
"dropdown-menu"
>
<
a
href
=
"{{ route('area.editar', ['id' =>
$subArea->id
]) }}"
class
=
"dropdown-item"
>
<
a
href
=
"{{ route('
sub
area.editar', ['id' =>
$subArea->id
]) }}"
class
=
"dropdown-item"
>
<
img
src
=
"
{
{asset('img/icons/edit-regular.svg')}
}
"
class
=
"icon-card"
alt
=
""
>
Editar
</
a
>
<
form
method
=
"POST"
action
=
"{{ route('area.deletar', ['id' =>
$subArea->id
]) }}"
>
<
form
method
=
"POST"
action
=
"{{ route('
sub
area.deletar', ['id' =>
$subArea->id
]) }}"
>
{{
csrf_field
()
}}
<
button
type
=
"submit"
class
=
"dropdown-item"
>
<
img
src
=
"
{
{asset('img/icons/trash-alt-regular.svg')}
}
"
class
=
"icon-card"
alt
=
""
>
...
...
resources/views/naturezas/area/index.blade.php
View file @
31c22774
...
...
@@ -7,10 +7,7 @@
<
div
class
=
"container"
>
<
div
class
=
"row"
>
<
div
class
=
"col-sm-10"
>
<
h3
>
Editais
</
h3
>
</
div
>
<
div
class
=
"col-sm-2"
>
<
a
href
=
"#"
class
=
"btn btn-primary"
>
Criar
Edital
</
a
>
<
h3
>
{{
__
(
'Áreas'
)
}}
</
h3
>
</
div
>
</
div
>
</
div
>
...
...
@@ -18,37 +15,33 @@
<
table
class
=
"table table-bordered"
>
<
thead
>
<
tr
>
<
th
scope
=
"col"
>
Nome
do
Edital
</
th
>
<
th
scope
=
"col"
>
Data
de
Criação
</
th
>
<
th
scope
=
"col"
>
Nome
</
th
>
<
th
scope
=
"col"
>
Opção
</
th
>
</
tr
>
</
thead
>
<
tbody
>
{{
--
@
foreach
(
$
eventos
as
$evento
)
@
foreach
(
$
areas
as
$area
)
<
tr
>
<
td
>
<
a
href
=
"{{
route('
evento.visualizar
',['id'=>
$evento
->id
])
}}"
class
=
"visualizarEvento"
>
{{
$
evento
->
nome
}}
<
a
href
=
"{{ route('
area.show
',
['id'
=>
$area
->id
]) }}"
class
=
"visualizarEvento"
>
{{
$
area
->
nome
}}
</
a
>
</
td
>
<
td
>
10
/
05
/
2020
</
td
>
<
td
>
<
div
class
=
"btn-group dropright dropdown-options"
>
<
a
id
=
"options"
class
=
"dropdown-toggle "
data
-
toggle
=
"dropdown"
aria
-
haspopup
=
"true"
aria
-
expanded
=
"false"
>
</
a
>
<
div
class
=
"dropdown-menu"
>
<
a
href
=
"{{ route('
coord.detalhesEvento', ['eventoI
d' =>
$
evento
->id
]) }}"
class
=
"dropdown-item"
>
<
a
href
=
"{{ route('
area.show', ['i
d' =>
$
area
->id
]) }}"
class
=
"dropdown-item"
>
<
img
src
=
"
{
{asset('img/icons/eye-regular.svg')}
}
"
class
=
"icon-card"
alt
=
""
>
Detalhes
</
a
>
<
a
href
=
"
{
{route('
evento
.editar',
$evento
->id
)
}
}
"
class
=
"dropdown-item"
>
<
a
href
=
"{{
route('
area
.editar',
['id' =>
$area
->id
])
}}"
class
=
"dropdown-item"
>
<
img
src
=
"
{
{asset('img/icons/edit-regular.svg')}
}
"
class
=
"icon-card"
alt
=
""
>
Editar
</
a
>
<
form
method
=
"POST"
action
=
"
{
{route('
evento
.deletar',
$evento
->id
)
}
}
"
>
<
form
method
=
"POST"
action
=
"{{
route('
area
.deletar',
['id' =>
$area
->id
])
}}"
>
{{
csrf_field
()
}}
{{
method_field
(
'DELETE'
)
}}
<
button
type
=
"submit"
class
=
"dropdown-item"
>
<
img
src
=
"
{
{asset('img/icons/trash-alt-regular.svg')}
}
"
class
=
"icon-card"
alt
=
""
>
Deletar
...
...
@@ -59,7 +52,7 @@
</
div
>
</
td
>
</
tr
>
@
endforeach
--
}}
@
endforeach
</
tbody
>
</
table
>
</
div
>
...
...
resources/views/naturezas/area/nova_area.blade.php
View file @
31c22774
...
...
@@ -9,7 +9,7 @@
</
div
>
</
div
>
<
div
class
=
"row"
>
<
form
method
=
"POST"
action
=
"{{ route('area.salvar', ['id' =>
$grandeArea
i
d
])}}"
>
<
form
method
=
"POST"
action
=
"{{ route('area.salvar', ['id' =>
$grandeArea
I
d
])}}"
>
@
csrf
<
div
class
=
"col-sm-12"
>
<
label
for
=
"nome"
class
=
"col-form-label"
>
{{
__
(
'Nome'
)
}}
</
label
>
...
...
resources/views/naturezas/index.blade.php
View file @
31c22774
...
...
@@ -19,7 +19,7 @@
</
div
>
<
div
class
=
"col-sm-4 d-flex justify-content-center"
>
<
a
href
=
"
#
"
style
=
"text-decoration:none; color: inherit;"
>
<
a
href
=
"
{{ route('area.index') }}
"
style
=
"text-decoration:none; color: inherit;"
>
<
div
class
=
"card text-center "
style
=
"border-radius: 30px; width: 18rem;"
>
<
div
class
=
"card-body d-flex justify-content-center"
>
<
h2
style
=
"padding-top:15px"
>
Area
</
h2
>
...
...
@@ -28,7 +28,7 @@
</
a
>
</
div
>
<
div
class
=
"col-sm-4 d-flex justify-content-center"
>
<
a
href
=
"
#
"
style
=
"text-decoration:none; color: inherit;"
>
<
a
href
=
"
{{ route('subarea.index') }}
"
style
=
"text-decoration:none; color: inherit;"
>
<
div
class
=
"card text-center "
style
=
"border-radius: 30px; width: 18rem;"
>
<
div
class
=
"card-body d-flex justify-content-center"
>
<
h2
style
=
"padding-top:15px"
>
Subárea
</
h2
>
...
...
resources/views/naturezas/subArea/editar_subarea.blade.php
0 → 100644
View file @
31c22774
@
extends
(
'layouts.app'
)
@
section
(
'content'
)
<
div
class
=
"container"
>
<
div
class
=
"row"
>
<
div
class
=
"col-sm-12"
>
<
h2
style
=
"margin-top: 100px; "
>
{{
__
(
'Editar uma subárea'
)
}}
</
h2
>
</
div
>
</
div
>
<
div
class
=
"row"
>
<
form
method
=
"POST"
action
=
"{{ route('subarea.atualizar', ['id' =>
$subarea->id
])}}"
>
@
csrf
<
div
class
=
"col-sm-12"
>
<
label
for
=
"nome"
class
=
"col-form-label"
>
{{
__
(
'Nome'
)
}}
</
label
>
<
input
id
=
"nome"
type
=
"text"
class
=
"form-control @error('nome') is-invalid @enderror"
name
=
"nome"
value
=
"{{
$subarea->nome
}}"
required
autocomplete
=
"nome"
autofocus
>
@
error
(
'nome'
)
<
span
class
=
"invalid-feedback"
role
=
"alert"
>
<
strong
>
{{
$message
}}
</
strong
>
</
span
>
@
enderror
<
button
type
=
"submit"
class
=
"btn btn-primary"
style
=
"position:relative;top:100px;"
>
{{
__
(
'Salvar'
)
}}
</
button
>
</
div
>
</
form
>
</
div
>
</
div
>
@
endsection
\ No newline at end of file
resources/views/naturezas/subArea/index.blade.php
View file @
31c22774
...
...
@@ -2,8 +2,58 @@
@
section
(
'content'
)
<
div
class
=
"container"
>
<
div
class
=
"container"
>
<
div
class
=
"row"
>
@
if
(
session
(
'mensagem'
))
<
div
class
=
"col-md-12"
style
=
"margin-top: 100px;"
>
<
div
class
=
"alert alert-success"
>
<
p
>
{{
session
(
'mensagem'
)}}
</
p
>
</
div
>
</
div
>
@
endif
<
div
class
=
"col-sm-9"
>
<
h2
style
=
"margin-top: 100px; "
>
{{
__
(
'Subáreas'
)
}}
</
h2
>
</
div
>
</
div
>
<
hr
>
<
table
class
=
"table table-bordered"
>
<
thead
>
<
tr
>
<
th
scope
=
"col"
>
Nome
</
th
>
<
th
scope
=
"col"
>
Opção
</
th
>
</
tr
>
</
thead
>
<
tbody
>
@
foreach
(
$subAreas
as
$subArea
)
<
tr
>
<
td
>
{{
$subArea
->
nome
}}
</
td
>
<
td
>
<
div
class
=
"btn-group dropright dropdown-options"
>
<
a
id
=
"options"
class
=
"dropdown-toggle "
data
-
toggle
=
"dropdown"
aria
-
haspopup
=
"true"
aria
-
expanded
=
"false"
>
</
a
>
<
div
class
=
"dropdown-menu"
>
<
a
href
=
"{{ route('subarea.editar', ['id' =>
$subArea->id
]) }}"
class
=
"dropdown-item"
>
<
img
src
=
"
{
{asset('img/icons/edit-regular.svg')}
}
"
class
=
"icon-card"
alt
=
""
>
Editar
</
a
>
<
form
method
=
"POST"
action
=
"{{ route('subarea.deletar', ['id' =>
$subArea->id
]) }}"
>
{{
csrf_field
()
}}
<
button
type
=
"submit"
class
=
"dropdown-item"
>
<
img
src
=
"
{
{asset('img/icons/trash-alt-regular.svg')}
}
"
class
=
"icon-card"
alt
=
""
>
Deletar
</
button
>
</
form
>
</
div
>
</
div
>
</
td
>
</
tr
>
@
endforeach
</
tbody
>
</
table
>
</
div
>
@
endsection
\ No newline at end of file
resources/views/naturezas/subArea/nova_subarea.blade.php
0 → 100644
View file @
31c22774
@
extends
(
'layouts.app'
)
@
section
(
'content'
)
<
div
class
=
"container"
>
<
div
class
=
"row"
>
<
div
class
=
"col-sm-12"
>
<
h2
style
=
"margin-top: 100px; "
>
{{
__
(
'Criar uma nova subárea'
)
}}
</
h2
>
</
div
>
</
div
>
<
div
class
=
"row"
>
<
form
method
=
"POST"
action
=
"{{ route('subarea.salvar', ['id' =>
$areaId
])}}"
>
@
csrf
<
div
class
=
"col-sm-12"
>
<
label
for
=
"nome"
class
=
"col-form-label"
>
{{
__
(
'Nome'
)
}}
</
label
>
<
input
id
=
"nome"
type
=
"text"
class
=
"form-control @error('nome') is-invalid @enderror"
name
=
"nome"
value
=
"{{ old('nome') }}"
required
autocomplete
=
"nome"
autofocus
>
@
error
(
'nome'
)
<
span
class
=
"invalid-feedback"
role
=
"alert"
>
<
strong
>
{{
$message
}}
</
strong
>
</
span
>
@
enderror
<
button
type
=
"submit"
class
=
"btn btn-primary"
style
=
"position:relative;top:100px;"
>
{{
__
(
'Salvar'
)
}}
</
button
>
</
div
>
</
form
>
</
div
>
</
div
>
@
endsection
\ No newline at end of file
routes/web.php
View file @
31c22774
...
...
@@ -54,7 +54,7 @@ Route::get('/naturezas/grande-area/detalhes/{id}', 'GrandeAreaController@show')-
Route
::
get
(
'/naturezas/grande-area/editar/{id}'
,
'GrandeAreaController@edit'
)
->
middleware
(
'checkAdministrador'
)
->
name
(
'grandearea.editar'
);
Route
::
post
(
'/naturezas/grande-area/atualizar/{id}'
,
'GrandeAreaController@update'
)
->
middleware
(
'checkAdministrador'
)
->
name
(
'grandearea.atualizar'
);
Route
::
post
(
'/naturezas/grande-area/excluir/{id}'
,
'GrandeAreaController@destroy'
)
->
middleware
(
'checkAdministrador'
)
->
name
(
'grandearea.deletar'
);
//Rotas das areas
//Rotas das areas
, id's de nova e salvar são os ids da grande área a qual a nova área pertence
Route
::
get
(
'/naturezas/areas'
,
'AreaController@index'
)
->
middleware
(
'checkAdministrador'
)
->
name
(
'area.index'
);
Route
::
get
(
'/naturezas/{id}/area/nova'
,
'AreaController@create'
)
->
middleware
(
'checkAdministrador'
)
->
name
(
'area.criar'
);
Route
::
post
(
'/naturezas/{id}/area/salvar'
,
'AreaController@store'
)
->
middleware
(
'checkAdministrador'
)
->
name
(
'area.salvar'
);
...
...
@@ -62,6 +62,15 @@ Route::get('/naturezas/area/detalhes/{id}', 'AreaController@show')->middleware('
Route
::
get
(
'/naturezas/area/editar/{id}'
,
'AreaController@edit'
)
->
middleware
(
'checkAdministrador'
)
->
name
(
'area.editar'
);
Route
::
post
(
'/naturezas/area/atualizar/{id}'
,
'AreaController@update'
)
->
middleware
(
'checkAdministrador'
)
->
name
(
'area.atualizar'
);
Route
::
post
(
'/naturezas/area/excluir/{id}'
,
'AreaController@destroy'
)
->
middleware
(
'checkAdministrador'
)
->
name
(
'area.deletar'
);
//Rotas das subareas, id's de nova e salvar são os ids da área a qual a nova subárea pertence
Route
::
get
(
'/naturezas/subareas'
,
'SubAreaController@index'
)
->
middleware
(
'checkAdministrador'
)
->
name
(
'subarea.index'
);
Route
::
get
(
'/naturezas/{id}/subarea/nova'
,
'SubAreaController@create'
)
->
middleware
(
'checkAdministrador'
)
->
name
(
'subarea.criar'
);
Route
::
post
(
'/naturezas/{id}/subarea/salvar'
,
'SubAreaController@store'
)
->
middleware
(
'checkAdministrador'
)
->
name
(
'subarea.salvar'
);
Route
::
get
(
'/naturezas/subarea/detalhes/{id}'
,
'SubAreaController@show'
)
->
middleware
(
'checkAdministrador'
)
->
name
(
'subarea.show'
);
Route
::
get
(
'/naturezas/subarea/editar/{id}'
,
'SubAreaController@edit'
)
->
middleware
(
'checkAdministrador'
)
->
name
(
'subarea.editar'
);
Route
::
post
(
'/naturezas/subarea/atualizar/{id}'
,
'SubAreaController@update'
)
->
middleware
(
'checkAdministrador'
)
->
name
(
'subarea.atualizar'
);
Route
::
post
(
'/naturezas/subarea/excluir/{id}'
,
'SubAreaController@destroy'
)
->
middleware
(
'checkAdministrador'
)
->
name
(
'subarea.deletar'
);
// Rotas Coordenador
Route
::
get
(
'/coordenador/home'
,
'CoordenadorComissaoController@index'
)
->
name
(
'coordenador.index'
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment