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
319e67d8
"app/Http/vscode:/vscode.git/clone" did not exist on "23132513616b57ddc2bfa8895b65f7e1e235ab87"
Commit
319e67d8
authored
Jun 01, 2020
by
carlos
Browse files
crud naturezas
parent
7387b6c8
Changes
11
Expand all
Show whitespace changes
Inline
Side-by-side
app/Http/Controllers/AdministradorController.php
View file @
319e67d8
...
...
@@ -10,6 +10,7 @@ use App\Avaliador;
use
App\AdministradorResponsavel
;
use
App\Participante
;
use
App\Proponente
;
use
App\Natureza
;
use
Illuminate\Support\Facades\Hash
;
use
App\Evento
;
...
...
@@ -20,8 +21,8 @@ class AdministradorController extends Controller
return
view
(
'administrador.index'
);
}
public
function
naturezas
(){
return
view
(
'naturezas.index'
);
$naturezas
=
Natureza
::
orderBy
(
'nome'
)
->
get
();
return
view
(
'naturezas.index'
)
->
with
([
'naturezas'
=>
$naturezas
])
;
}
public
function
usuarios
(){
$users
=
User
::
orderBy
(
'name'
)
->
get
();
...
...
app/Http/Controllers/EventoController.php
View file @
319e67d8
...
...
@@ -304,15 +304,15 @@ class EventoController extends Controller
{
$evento
=
Evento
::
find
(
$id
);
$areas
=
Area
::
where
(
'eventoId'
,
$id
);
//
$areas = Area::where('eventoId', $id);
$atividades
=
Atividade
::
where
(
'eventoId'
,
$id
);
$comissao
=
ComissaoEvento
::
where
(
'eventosId'
,
$id
);
$revisores
=
Revisor
::
where
(
'eventoId'
,
$id
);
$trabalhos
=
Trabalho
::
where
(
'evento
I
d'
,
$id
);
$trabalhos
=
Trabalho
::
where
(
'evento
_i
d'
,
$id
);
if
(
isset
(
$areas
)){
$areas
->
delete
();
}
//
if(isset($areas)){
//
$areas->delete();
//
}
if
(
isset
(
$atividades
)){
$atividades
->
delete
();
}
...
...
app/Http/Controllers/NaturezaController.php
0 → 100644
View file @
319e67d8
<?php
namespace
App\Http\Controllers
;
use
Illuminate\Http\Request
;
use
App\Natureza
;
class
NaturezaController
extends
Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public
function
index
()
{
//
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public
function
create
()
{
//
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public
function
store
(
Request
$request
)
{
$validated
=
$request
->
validate
([
'nome'
=>
'required'
]);
$natureza
=
new
Natureza
();
$natureza
->
nome
=
$request
->
nome
;
$natureza
->
save
();
return
redirect
(
route
(
'admin.naturezas'
)
)
->
with
([
'mensagem'
=>
'Natureza salva 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
)
{
//
}
/**
* 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
([
'nomeEditavel'
=>
'required'
,
]);
$natureza
=
Natureza
::
find
(
$id
);
$natureza
->
nome
=
$request
->
nomeEditavel
;
$natureza
->
update
();
return
redirect
(
route
(
'admin.naturezas'
)
)
->
with
([
'mensagem'
=>
"Natureza editada com sucesso"
]);
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public
function
destroy
(
$id
)
{
$natureza
=
Natureza
::
find
(
$id
);
$natureza
->
delete
();
return
redirect
(
route
(
'admin.naturezas'
)
)
->
with
([
'mensagem'
=>
"Natureza deletada com sucesso"
]);
}
}
app/Natureza.php
0 → 100644
View file @
319e67d8
<?php
namespace
App
;
use
Illuminate\Database\Eloquent\Model
;
class
Natureza
extends
Model
{
//
}
composer.lock
View file @
319e67d8
This diff is collapsed.
Click to expand it.
database/migrations/2020_06_01_174832_create_naturezas_table.php
0 → 100644
View file @
319e67d8
<?php
use
Illuminate\Database\Migrations\Migration
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Support\Facades\Schema
;
class
CreateNaturezasTable
extends
Migration
{
/**
* Run the migrations.
*
* @return void
*/
public
function
up
()
{
Schema
::
create
(
'naturezas'
,
function
(
Blueprint
$table
)
{
$table
->
bigIncrements
(
'id'
);
$table
->
string
(
'nome'
);
$table
->
timestamps
();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
Schema
::
dropIfExists
(
'naturezas'
);
}
}
database/seeds/DatabaseSeeder.php
View file @
319e67d8
...
...
@@ -22,6 +22,7 @@ class DatabaseSeeder extends Seeder
$this
->
call
(
FuncaoParticipanteSeeder
::
class
);
$this
->
call
(
CoordenadorComissaoSeeder
::
class
);
$this
->
call
(
ParticipanteSeeder
::
class
);
$this
->
call
(
NaturezaSeeder
::
class
);
// $this->call(UsersTableSeeder::class);
...
...
database/seeds/NaturezaSeeder.php
0 → 100644
View file @
319e67d8
<?php
use
Illuminate\Database\Seeder
;
class
NaturezaSeeder
extends
Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public
function
run
()
{
DB
::
table
(
'naturezas'
)
->
insert
([
'nome'
=>
'Ensino'
,
]);
DB
::
table
(
'naturezas'
)
->
insert
([
'nome'
=>
'Pesquisa'
,
]);
DB
::
table
(
'naturezas'
)
->
insert
([
'nome'
=>
'Extensão'
,
]);
}
}
resources/views/administrador/index.blade.php
View file @
319e67d8
...
...
@@ -19,7 +19,7 @@
</
div
>
<
div
class
=
"col-sm-3 d-flex justify-content-center"
>
<
a
href
=
"{{ route('
grandearea.index
') }}"
style
=
"text-decoration:none; color: inherit;"
>
<
a
href
=
"{{ route('
admin.naturezas
') }}"
style
=
"text-decoration:none; color: inherit;"
>
<
div
class
=
"card text-center "
style
=
"border-radius: 30px; width: 13rem;height: 15rem;"
>
<
div
class
=
"card-body d-flex justify-content-center"
>
<
h2
style
=
"padding-top:15px"
>
Natureza
</
h2
>
...
...
resources/views/naturezas/index.blade.php
View file @
319e67d8
...
...
@@ -2,43 +2,150 @@
@
section
(
'content'
)
<
div
class
=
"container"
>
<
h2
style
=
"margin-top: 100px; "
>
Administrador
</
h2
>
<
div
class
=
"row justify-content-center d-flex align-items-center"
>
<
div
class
=
"col-sm-4 d-flex justify-content-center "
>
<
a
href
=
"{{ route('grandearea.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"
>
Grande
Area
</
h2
>
<
div
class
=
"container"
>
{{
--
Modal
criar
nova
natureza
--
}}
<
div
class
=
"modal fade"
id
=
"modalNewCenter"
tabindex
=
"-1"
role
=
"dialog"
aria
-
labelledby
=
"modalCenterTitle"
aria
-
hidden
=
"true"
>
<
div
class
=
"modal-dialog modal-dialog-centered"
role
=
"document"
>
<
div
class
=
"modal-content"
>
<
div
class
=
"modal-header"
>
<
h5
class
=
"modal-title"
id
=
"exampleModalLongTitle"
>
{{
__
(
'Nova natureza'
)}}
</
h5
>
<
button
type
=
"button"
class
=
"close"
data
-
dismiss
=
"modal"
aria
-
label
=
"Close"
>
<
span
aria
-
hidden
=
"true"
>&
times
;
</
span
>
</
button
>
</
div
>
<
div
class
=
"modal-body"
>
<
form
id
=
"formNew"
method
=
"POST"
action
=
"{{ route('natureza.salvar') }}"
>
@
csrf
<
input
form
=
"formNew"
type
=
"text"
value
=
""
class
=
"form-control @error('nome') is-invalid @enderror"
name
=
"nome"
required
autocomplete
=
"nome"
autofocus
>
@
error
(
'nome'
)
<
span
class
=
"invalid-feedback"
role
=
"alert"
>
<
strong
>
{{
$message
}}
</
strong
>
</
span
>
@
enderror
</
form
>
</
div
>
<
div
class
=
"modal-footer"
>
<
button
type
=
"button"
class
=
"btn btn-secondary"
data
-
dismiss
=
"modal"
>
{{
__
(
'Cancelar'
)}}
</
button
>
<
button
type
=
"button"
onclick
=
"submeterFormNew()"
class
=
"btn btn-primary"
>
{{
__
(
'Salvar'
)}}
</
button
>
</
div
>
</
div
>
</
div
>
</
a
>
</
div
>
<
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; "
>
{{
__
(
'Naturezas'
)
}}
</
h2
>
</
div
>
<
div
class
=
"col-sm-3"
>
<
a
href
=
""
class
=
"btn btn-primary"
style
=
"position:relative;top:100px;"
data
-
toggle
=
"modal"
data
-
target
=
"#modalNewCenter"
>
{{
__
(
'Criar natureza'
)
}}
</
a
>
</
div
>
</
div
>
<
div
class
=
"col-sm-4 d-flex justify-content-center"
>
<
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
>
<
hr
>
<
table
class
=
"table table-bordered"
>
<
thead
>
<
tr
>
<
th
scope
=
"col"
>
Nome
</
th
>
<
th
scope
=
"col"
>
Data
de
criação
</
th
>
<
th
scope
=
"col"
>
Opção
</
th
>
</
tr
>
</
thead
>
<
tbody
>
@
foreach
(
$naturezas
as
$natureza
)
<!--
Modal
Editar
-->
<
div
class
=
"modal fade"
id
=
"modalEditCenter
{
{$natureza->id}
}
"
tabindex
=
"-1"
role
=
"dialog"
aria
-
labelledby
=
"modalCenterTitle"
aria
-
hidden
=
"true"
>
<
div
class
=
"modal-dialog modal-dialog-centered"
role
=
"document"
>
<
div
class
=
"modal-content"
>
<
div
class
=
"modal-header"
>
<
h5
class
=
"modal-title"
id
=
"exampleModalLongTitle"
>
{{
__
(
'Editar natureza'
)}}
</
h5
>
<
button
type
=
"button"
class
=
"close"
data
-
dismiss
=
"modal"
aria
-
label
=
"Close"
>
<
span
aria
-
hidden
=
"true"
>&
times
;
</
span
>
</
button
>
</
div
>
<
div
class
=
"modal-body"
>
<
form
id
=
"formEdit{{
$natureza->id
}}"
action
=
"{{ route('natureza.atualizar', ['id' =>
$natureza->id
]) }}"
>
@
csrf
<
input
form
=
"formEdit{{
$natureza->id
}}"
type
=
"text"
value
=
"{{
$natureza->nome
}}"
class
=
"form-control @error('nomeEditavel') is-invalid @enderror"
name
=
"nomeEditavel"
required
autocomplete
=
"nome"
autofocus
>
@
error
(
'nomeEditavel'
)
<
span
class
=
"invalid-feedback"
role
=
"alert"
>
<
strong
>
{{
$message
}}
</
strong
>
</
span
>
@
enderror
</
form
>
</
div
>
</
a
>
<
div
class
=
"modal-footer"
>
<
button
type
=
"button"
class
=
"btn btn-secondary"
data
-
dismiss
=
"modal"
>
{{
__
(
'Cancelar'
)}}
</
button
>
<
button
type
=
"button"
onclick
=
"submeterFormEdit('{{
$natureza->id
}}')"
class
=
"btn btn-primary"
>
{{
__
(
'Salvar'
)}}
</
button
>
</
div
>
<
div
class
=
"col-sm-4 d-flex justify-content-center"
>
<
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
>
</
div
>
</
div
>
</
div
>
<!--
Modal
Excluir
-->
<
div
class
=
"modal fade"
id
=
"modalDelCenter
{
{$natureza->id}
}
"
tabindex
=
"-1"
role
=
"dialog"
aria
-
labelledby
=
"modalCenterTitle"
aria
-
hidden
=
"true"
>
<
div
class
=
"modal-dialog modal-dialog-centered"
role
=
"document"
>
<
div
class
=
"modal-content"
>
<
div
class
=
"modal-header"
>
<
h5
class
=
"modal-title"
id
=
"exampleModalLongTitle"
>
{{
__
(
'Deletar natureza'
)}}
</
h5
>
<
button
type
=
"button"
class
=
"close"
data
-
dismiss
=
"modal"
aria
-
label
=
"Close"
>
<
span
aria
-
hidden
=
"true"
>&
times
;
</
span
>
</
button
>
</
div
>
<
div
class
=
"modal-body"
>
{{
__
(
'Tem certeza que deseja deletar essa natureza?'
)}}
</
div
>
<
div
class
=
"modal-footer"
>
<
button
type
=
"button"
class
=
"btn btn-secondary"
data
-
dismiss
=
"modal"
>
{{
__
(
'Não'
)}}
</
button
>
<
a
href
=
"{{ route('natureza.deletar', ['id' =>
$natureza->id
]) }}"
type
=
"button"
onclick
=
"submeterFormDel('{{
$natureza->id
}}')"
class
=
"btn btn-primary"
>
{{
__
(
'Sim'
)}}
</
a
>
</
div
>
</
div
>
</
div
>
</
div
>
<
tr
>
<
td
>
{{
$natureza
->
nome
}}
</
td
>
<
td
>
{{
$natureza
->
creat_at
}}
</
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
class
=
"dropdown-item"
data
-
toggle
=
"modal"
data
-
target
=
"#modalEditCenter
{
{$natureza->id}
}
"
class
=
"dropdown-item"
>
<
img
src
=
"
{
{asset('img/icons/edit-regular.svg')}
}
"
class
=
"icon-card"
alt
=
""
>
{{
__
(
'Editar'
)}}
</
a
>
<
a
class
=
"dropdown-item"
data
-
toggle
=
"modal"
data
-
target
=
"#modalDelCenter
{
{$natureza->id}
}
"
class
=
"dropdown-item"
>
<
img
src
=
"
{
{asset('img/icons/trash-alt-regular.svg')}
}
"
class
=
"icon-card"
alt
=
""
>
{{
__
(
'Deletar'
)}}
</
a
>
</
div
>
</
div
>
</
td
>
</
tr
>
@
endforeach
</
tbody
>
</
table
>
</
div
>
@
endsection
@
section
(
'javascript'
)
<
script
>
function
submeterFormNew
()
{
var
form
=
document
.
getElementById
(
'formNew'
);
form
.
submit
();
}
function
submeterFormEdit
(
id
)
{
var
form
=
document
.
getElementById
(
'formEdit'
+
id
);
form
.
submit
();
}
</
script
>
@
endsection
\ No newline at end of file
routes/web.php
View file @
319e67d8
...
...
@@ -114,8 +114,17 @@ Route::prefix('usuarios')->name('admin.')->group(function(){
Route
::
prefix
(
'naturezas'
)
->
group
(
function
(){
//########### Rotas das naturezas ###############################
//########### Rotas das grandes areas ##############################
Route
::
get
(
'/'
,
'AdministradorController@naturezas'
)
->
name
(
'admin.naturezas'
);
Route
::
get
(
'/index'
,
'NaturezaController@index'
)
->
name
(
'natureza.index'
);
Route
::
get
(
'/nova'
,
'NaturezaController@create'
)
->
name
(
'natureza.criar'
);
Route
::
post
(
'/salvar'
,
'NaturezaController@store'
)
->
name
(
'natureza.salvar'
);
Route
::
get
(
'/detalhes/{id}'
,
'NaturezaController@show'
)
->
name
(
'natureza.show'
);
Route
::
get
(
'/editar/{id}'
,
'NaturezaController@edit'
)
->
name
(
'natureza.editar'
);
Route
::
get
(
'/atualizar/{id}'
,
'NaturezaController@update'
)
->
name
(
'natureza.atualizar'
);
Route
::
get
(
'/excluir/{id}'
,
'NaturezaController@destroy'
)
->
name
(
'natureza.deletar'
);
//########### Rotas das grandes areas ##############################
Route
::
get
(
'/grande-area'
,
'GrandeAreaController@index'
)
->
name
(
'grandearea.index'
);
Route
::
get
(
'/grande-area/nova'
,
'GrandeAreaController@create'
)
->
name
(
'grandearea.criar'
);
Route
::
post
(
'/grande-area/salvar'
,
'GrandeAreaController@store'
)
->
name
(
'grandearea.salvar'
);
...
...
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