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
pad-upe
Commits
0cedb1ec
Commit
0cedb1ec
authored
Mar 28, 2022
by
Abraão Barbosa
Browse files
Merge remote-tracking branch 'origin/feat_editar_perfil' into update_dashboard
parents
b736cf58
e63111eb
Changes
10
Hide whitespace changes
Inline
Side-by-side
app/Http/Controllers/UserController.php
0 → 100644
View file @
0cedb1ec
<?php
namespace
App\Http\Controllers
;
use
App\Models\User
;
use
Illuminate\Http\Request
;
use
Illuminate\Support\Facades\Auth
;
class
UserController
extends
Controller
{
const
MENU_UPDATE_PERFIL
=
0
;
public
function
editPerfil
()
{
return
view
(
'user.update_perfil'
,
[
'index_menu'
=>
self
::
MENU_UPDATE_PERFIL
]);
}
public
function
updatePerfil
(
Request
$request
)
{
$validator
=
User
::
validator
(
$request
->
all
());
if
(
$validator
->
fails
())
{
return
redirect
()
->
back
()
->
withErrors
(
$validator
->
errors
());
}
$user
=
User
::
find
(
Auth
::
user
()
->
id
);
$user
->
fill
(
$request
->
all
());
$user
->
save
();
return
redirect
()
->
route
(
'edit_perfil'
)
->
with
(
'success'
,
'Salvo com sucesso!'
);
}
public
function
updatePassword
(
Request
$request
)
{
$validator
=
User
::
validator
(
$request
->
all
(),
true
);
// if($validator->fails()) {
// return redirect()->back()->withErrors($validator->errors());
// }
// $user = User::find(Auth::user()->id);
// $user->fill($request->all());
// $user->save();
// return redirect()->route('edit_perfil')->with('success', 'Salvo com sucesso!');
}
}
app/Models/User.php
View file @
0cedb1ec
...
@@ -6,6 +6,8 @@ use Illuminate\Contracts\Auth\MustVerifyEmail;
...
@@ -6,6 +6,8 @@ use Illuminate\Contracts\Auth\MustVerifyEmail;
use
Illuminate\Database\Eloquent\Factories\HasFactory
;
use
Illuminate\Database\Eloquent\Factories\HasFactory
;
use
Illuminate\Foundation\Auth\User
as
Authenticatable
;
use
Illuminate\Foundation\Auth\User
as
Authenticatable
;
use
Illuminate\Notifications\Notifiable
;
use
Illuminate\Notifications\Notifiable
;
use
Illuminate\Support\Facades\Validator
;
use
Illuminate\Validation\ValidationException
;
use
Laravel\Sanctum\HasApiTokens
;
use
Laravel\Sanctum\HasApiTokens
;
class
User
extends
Authenticatable
class
User
extends
Authenticatable
...
@@ -46,6 +48,37 @@ class User extends Authenticatable
...
@@ -46,6 +48,37 @@ class User extends Authenticatable
'email_verified_at'
=>
'datetime'
'email_verified_at'
=>
'datetime'
];
];
/**
* Validar os campos de acordo com as regras implementadas
*
*/
public
static
function
validator
(
$attributes
,
$rule_password
=
false
)
{
$rules
=
[
'email'
=>
[
'required'
,
'email'
,
],
'name'
=>
[
'required'
,
]
];
if
(
$rule_password
)
{
$rules
=
[
'password'
=>
[
'required'
,
'min:6'
],
'password_confirmation'
=>
[],
];
}
$messages
=
[
// 'unique' => "O :attribute já está registrado no sistema",
'required'
=>
"O :attribute precisa ser preenchido"
,
];
try
{
return
Validator
::
make
(
$attributes
,
$rules
,
$messages
);
}
catch
(
ValidationException
$exception
)
{
}
}
/**
/**
* Get Curso with curso.id = user.curso_id
* Get Curso with curso.id = user.curso_id
*
*
...
@@ -95,6 +128,13 @@ class User extends Authenticatable
...
@@ -95,6 +128,13 @@ class User extends Authenticatable
return
$this
->
type
===
self
::
TYPE_COORDINATOR
;
return
$this
->
type
===
self
::
TYPE_COORDINATOR
;
}
}
/**
* @return string
*/
public
function
attributeName
(
string
$attribute
)
{
return
$this
->
getTable
()
.
'-'
.
$attribute
;
}
/**
/**
* @return string
* @return string
*/
*/
...
@@ -102,5 +142,4 @@ class User extends Authenticatable
...
@@ -102,5 +142,4 @@ class User extends Authenticatable
{
{
return
$this
->
name
;
return
$this
->
name
;
}
}
}
}
resources/views/components/alerts.blade.php
0 → 100644
View file @
0cedb1ec
@
if
(
Session
::
has
(
'success'
)
)
<
div
class
=
"alert alert-success alert-dismissible fade show"
role
=
"alert"
>
{{
Session
::
get
(
'success'
)
}}
<
button
type
=
"button"
class
=
"close"
data
-
dismiss
=
"alert"
aria
-
label
=
"Close"
>
<
span
aria
-
hidden
=
"true"
>&
times
;
</
span
>
</
button
>
</
div
>
@
endif
@
if
(
Session
::
has
(
'fail'
)
)
<
div
class
=
"alert alert-danger alert-dismissible fade show"
role
=
"alert"
>
{{
Session
::
get
(
'fail'
)
}}
<
button
type
=
"button"
class
=
"close"
data
-
dismiss
=
"alert"
aria
-
label
=
"Close"
>
<
span
aria
-
hidden
=
"true"
>&
times
;
</
span
>
</
button
>
</
div
>
@
endif
@
if
(
Session
::
has
(
'error'
)
)
<
div
class
=
"alert alert-danger alert-dismissible fade show"
role
=
"alert"
>
{{
Session
::
get
(
'error'
)
}}
<
button
type
=
"button"
class
=
"close"
data
-
dismiss
=
"alert"
aria
-
label
=
"Close"
>
<
span
aria
-
hidden
=
"true"
>&
times
;
</
span
>
</
button
>
</
div
>
@
endif
resources/views/dashboard.blade.php
View file @
0cedb1ec
<x-app-layout>
<x-app-layout>
@section('title', 'Home')
<x-slot
name=
"main"
>
<x-slot
name=
"main"
>
<div
class=
"tab-content"
>
<div
class=
"tab-content"
>
@if(Auth::check())
@include('layouts.user-dashboard.update_perfil', ['user' => Auth::user()])
@endif
@if(Auth::user()->isTypeAdmin())
@if(Auth::user()->isTypeAdmin())
@include('layouts.user-dashboard.dashboard_admin')
@include('layouts.user-dashboard.dashboard_admin')
@endif
@endif
...
@@ -20,7 +17,6 @@
...
@@ -20,7 +17,6 @@
@if(Auth::user()->isTypeCoordinator())
@if(Auth::user()->isTypeCoordinator())
@include('layouts.user-dashboard.dashboard_coordinator')
@include('layouts.user-dashboard.dashboard_coordinator')
@endif
@endif
</div>
</div>
</x-slot>
</x-slot>
</x-app-layout>
</x-app-layout>
resources/views/layouts/app.blade.php
View file @
0cedb1ec
...
@@ -6,7 +6,8 @@
...
@@ -6,7 +6,8 @@
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1"
>
<meta
name=
"csrf-token"
content=
"{{ csrf_token() }}"
>
<meta
name=
"csrf-token"
content=
"{{ csrf_token() }}"
>
<title>
{{ config('app.name', 'Laravel') }}
</title>
<title>
{{ config('app.name') }} - @yield('title')
</title>
<!-- Styles -->
<!-- Styles -->
<link
rel=
"stylesheet"
href=
"https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"
<link
rel=
"stylesheet"
href=
"https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"
...
...
resources/views/layouts/main.blade.php
View file @
0cedb1ec
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1"
>
<meta
name=
"csrf-token"
content=
"{{ csrf_token() }}"
>
<meta
name=
"csrf-token"
content=
"{{ csrf_token() }}"
>
<title>
{{ config('app.name'
, 'Laravel') }}
</title>
<title>
{{ config('app.name'
) }} - @yield('title')
</title>
<!-- Styles -->
<!-- Styles -->
<link
rel=
"stylesheet"
href=
"https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"
<link
rel=
"stylesheet"
href=
"https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"
...
@@ -37,7 +37,7 @@
...
@@ -37,7 +37,7 @@
@section('nav')
@section('nav')
@show
@show
<main
class=
""
>
<main
class=
"
container-fluid
"
>
@section('body')
@section('body')
@show
@show
</main>
</main>
...
...
resources/views/layouts/navigation.blade.php
View file @
0cedb1ec
...
@@ -5,13 +5,9 @@
...
@@ -5,13 +5,9 @@
<div
class=
"d-flex justify-content-center flex-column content-user-info"
>
<div
class=
"d-flex justify-content-center flex-column content-user-info"
>
<div
class=
"font-medium text-base text-gray-800"
>
{{ Auth::user()->name }}
</div>
<div
class=
"font-medium text-base text-gray-800"
>
{{ Auth::user()->name }}
</div>
<div
class=
"font-medium text-sm text-gray-500"
>
{{ Auth::user()->email }}
</div>
<div
class=
"font-medium text-sm text-gray-500"
>
{{ Auth::user()->email }}
</div>
<a
id=
"btn-update-perfil"
class=
"btn"
>
<a
id=
"btn-update-perfil"
class=
"btn"
href=
"{{ route('edit_perfil') }}"
>
<svg
xmlns=
"http://www.w3.org/2000/svg"
width=
"16"
height=
"16"
fill=
"currentColor"
<i
class=
"bi bi-gear"
></i>
class=
"bi bi-gear-fill"
viewBox=
"0 0 16 16"
>
Editar Perfil
<path
d=
"M9.405 1.05c-.413-1.4-2.397-1.4-2.81 0l-.1.34a1.464 1.464 0 0 1-2.105.872l-.31-.17c-1.283-.698-2.686.705-1.987 1.987l.169.311c.446.82.023 1.841-.872 2.105l-.34.1c-1.4.413-1.4 2.397 0 2.81l.34.1a1.464 1.464 0 0 1 .872 2.105l-.17.31c-.698 1.283.705 2.686 1.987 1.987l.311-.169a1.464 1.464 0 0 1 2.105.872l.1.34c.413 1.4 2.397 1.4 2.81 0l.1-.34a1.464 1.464 0 0 1 2.105-.872l.31.17c1.283.698 2.686-.705 1.987-1.987l-.169-.311a1.464 1.464 0 0 1 .872-2.105l.34-.1c1.4-.413 1.4-2.397 0-2.81l-.34-.1a1.464 1.464 0 0 1-.872-2.105l.17-.31c.698-1.283-.705-2.686-1.987-1.987l-.311.169a1.464 1.464 0 0 1-2.105-.872l-.1-.34zM8 10.93a2.929 2.929 0 1 1 0-5.86 2.929 2.929 0 0 1 0 5.858z"
/>
</svg>
Editar
</a>
</a>
</div>
</div>
</div>
</div>
...
...
resources/views/layouts/user-dashboard/update_perfil.blade.php
deleted
100644 → 0
View file @
b736cf58
<div
class=
"tab-pane"
id=
"update-perfil"
role=
"tabpanel"
aria-labelledby=
"update-perfil-tab"
>
<div
class=
"d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom"
>
<h1
class=
"h2"
>
Atualizar Perfil
</h1>
</div>
</div>
\ No newline at end of file
resources/views/user/update_perfil.blade.php
0 → 100644
View file @
0cedb1ec
@
extends
(
'layouts.main'
)
@
section
(
'title'
,
'Atulizar Perfil'
)
@
section
(
'header'
)
@
include
(
'layouts.header'
,
[
'user'
=>
Auth
::
user
(),
])
@
endsection
@
section
(
'nav'
)
@
include
(
'layouts.navigation'
,
[
'index_menu'
=>
$index_menu
,
])
@
endsection
@
section
(
'body'
)
@
include
(
'components.alerts'
)
<
div
class
=
"d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom"
>
<
h1
class
=
"h2"
>
Atualizar
Perfil
</
h1
>
</
div
>
<
div
class
=
"content"
>
<!--
Tab
Panel
-->
<
div
class
=
"mb-4"
>
<
ul
class
=
"nav nav-tabs"
id
=
"tab-link"
role
=
"tablist"
>
<
li
class
=
"nav-item"
>
<
a
class
=
"nav-link active"
id
=
"perfil-tab"
data
-
toggle
=
"tab"
href
=
"#perfil"
role
=
"tab"
aria
-
controls
=
"perfil"
aria
-
selected
=
"true"
>
Perfil
</
a
>
</
li
>
<
li
class
=
"nav-item"
>
<
a
class
=
"nav-link"
id
=
"senha-tab"
data
-
toggle
=
"tab"
href
=
"#senha"
role
=
"tab"
aria
-
controls
=
"senha"
aria
-
selected
=
"false"
>
Senha
</
a
>
</
li
>
</
ul
>
</
div
>
<!--
Tab
Content
-->
<
div
class
=
"tab-content"
id
=
"tab-content"
>
<!--
Perfil
-->
<
div
class
=
"tab-pane fade show active"
id
=
"perfil"
role
=
"tabpanel"
aria
-
labelledby
=
"perfil-tab"
>
<
form
class
=
""
method
=
"post"
action
=
"{{ route('update_perfil') }}"
>
@
csrf
@
method
(
'POST'
)
<
div
class
=
"form-group"
>
<
label
for
=
"email"
>
E
-
mail
</
label
>
<
input
type
=
"email"
class
=
"form-control"
name
=
"email"
id
=
"email"
placeholder
=
"example@email.com"
value
=
"{{ Auth::user()->email }}"
>
<
small
id
=
"email_information"
class
=
"form-text text-muted"
>
{{
--
--
}}
</
small
>
@
error
(
'email'
)
<
span
class
=
"text-danger"
>
{{
$message
}}
</
span
>
@
enderror
</
div
>
<
div
class
=
"form-group"
>
<
label
for
=
"name"
>
Nome
</
label
>
<
input
type
=
"name"
class
=
"form-control"
name
=
"name"
id
=
"name"
placeholder
=
"Nome Completo"
value
=
"{{ Auth::user()->name }}"
>
<
small
id
=
"name_information"
class
=
"form-text text-muted"
>
{{
--
--
}}
</
small
>
@
error
(
'name'
)
<
span
class
=
"text-danger"
>
{{
$message
}}
</
span
>
@
enderror
</
div
>
<
div
class
=
"form-group"
>
<
label
for
=
"document"
>
CPF
</
label
>
<
input
type
=
"document"
class
=
"form-control"
name
=
"document"
id
=
"document"
placeholder
=
"Senha"
value
=
"{{ Auth::user()->document }}"
>
<
small
id
=
"document_information"
class
=
"form-text text-muted"
>
{{
--
--
}}
</
small
>
@
error
(
'document'
)
<
span
class
=
"text-danger"
>
{{
$message
}}
</
span
>
@
enderror
</
div
>
<
div
class
=
"d-flex justify-content-end"
>
<
button
class
=
"btn btn-success"
type
=
"submit"
>
Atualizar
</
button
>
</
div
>
</
form
>
</
div
>
<!--
Senha
-->
<
div
class
=
"tab-pane fade"
id
=
"senha"
role
=
"tabpanel"
aria
-
labelledby
=
"senha-tab"
>
<
form
method
=
"post"
action
=
"{{ route('update_password') }}"
>
@
csrf
@
method
(
'POST'
)
<
div
class
=
"row"
>
<
div
class
=
"col-6"
>
<
div
class
=
"form-group"
>
<
label
for
=
"password"
>
Senha
</
label
>
<
input
type
=
"password"
class
=
"form-control"
name
=
"password"
id
=
"password"
placeholder
=
"Senha"
>
<
small
id
=
"password_information"
class
=
"form-text text-muted"
>
{{
--
--
}}
</
small
>
@
error
(
'password'
)
<
span
class
=
"text-danger"
>
{{
$message
}}
</
span
>
@
enderror
</
div
>
</
div
>
<
div
class
=
"col-6"
>
<
div
class
=
"form-group"
>
<
label
for
=
"password_confirmation"
>
Confirmar
Senha
</
label
>
<
input
type
=
"password_confirmation"
class
=
"form-control"
name
=
"password_confirmation"
id
=
"password_confirmation"
placeholder
=
"Senha"
>
<
small
id
=
"password_confirmation_information"
class
=
"form-text text-muted"
>
{{
--
--
}}
</
small
>
@
error
(
'password_confirmation'
)
<
span
class
=
"text-danger"
>
{{
$message
}}
</
span
>
@
enderror
</
div
>
</
div
>
</
div
>
<
div
class
=
"d-flex justify-content-end"
>
<
button
class
=
"btn btn-success"
type
=
"submit"
>
Atualizar
</
button
>
</
div
>
</
form
>
</
div
>
</
div
>
</
div
>
@
endsection
routes/web.php
View file @
0cedb1ec
...
@@ -11,6 +11,7 @@ use App\Http\Controllers\DisciplinaController;
...
@@ -11,6 +11,7 @@ use App\Http\Controllers\DisciplinaController;
use
App\Http\Controllers\UnidadeController
;
use
App\Http\Controllers\UnidadeController
;
use
App\Http\Controllers\PADController
;
use
App\Http\Controllers\PADController
;
use
App\Http\Controllers\Tabelas\Ensino\EnsinoAulaController
;
use
App\Http\Controllers\Tabelas\Ensino\EnsinoAulaController
;
use
App\Http\Controllers\UserController
;
use
App\Models\Disciplina
;
use
App\Models\Disciplina
;
use
Illuminate\Support\Facades\Route
;
use
Illuminate\Support\Facades\Route
;
...
@@ -75,5 +76,9 @@ Route::get('/pad/dimensao/extensao', [ExtensaoController::class, 'index'])->name
...
@@ -75,5 +76,9 @@ Route::get('/pad/dimensao/extensao', [ExtensaoController::class, 'index'])->name
Route
::
post
(
'/pad/dimensao/ensino/aula/create'
,
[
EnsinoAulaController
::
class
,
'create'
])
->
name
(
'ensino_aula_create'
);
Route
::
post
(
'/pad/dimensao/ensino/aula/create'
,
[
EnsinoAulaController
::
class
,
'create'
])
->
name
(
'ensino_aula_create'
);
Route
::
delete
(
'/pad/dimensao/ensino/aula/delete/{id}'
,
[
EnsinoAulaController
::
class
,
'delete'
])
->
name
(
'ensino_aula_delete'
);
Route
::
delete
(
'/pad/dimensao/ensino/aula/delete/{id}'
,
[
EnsinoAulaController
::
class
,
'delete'
])
->
name
(
'ensino_aula_delete'
);
Route
::
get
(
'/user/edit/perfil'
,
[
UserController
::
class
,
'editPerfil'
])
->
name
(
'edit_perfil'
);
Route
::
post
(
'/user/update/perfil'
,
[
UserController
::
class
,
'updatePerfil'
])
->
name
(
'update_perfil'
);
Route
::
post
(
'/user/update/password'
,
[
UserController
::
class
,
'updatePassword'
])
->
name
(
'update_password'
);
/** json */
/** json */
Route
::
get
(
'/disciplina/{curso_id}'
,
[
DisciplinaController
::
class
,
'getDisciplinaByCurso'
])
->
name
(
'get_disciplina_by_curso'
);
Route
::
get
(
'/disciplina/{curso_id}'
,
[
DisciplinaController
::
class
,
'getDisciplinaByCurso'
])
->
name
(
'get_disciplina_by_curso'
);
\ No newline at end of file
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