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
fb75ebce
Commit
fb75ebce
authored
Apr 22, 2024
by
alissonalbuquerque
Browse files
update change profile
parent
08a8a673
Changes
4
Hide whitespace changes
Inline
Side-by-side
app/Http/Controllers/UserController.php
View file @
fb75ebce
...
@@ -159,15 +159,17 @@ class UserController extends Controller
...
@@ -159,15 +159,17 @@ class UserController extends Controller
}
}
public
function
actionChangeProfile
(
$user_id
,
$user_type_id
)
public
function
actionChangeProfile
(
$user_id
,
$user_type_id
)
{
{
$profiles
=
UserType
::
whereUserId
(
$user_id
)
->
whereStatus
(
Status
::
ATIVO
)
->
get
();
$profiles
=
UserType
::
whereUserId
(
$user_id
)
->
get
();
$profiles
->
each
(
function
(
UserType
$model
)
{
foreach
(
$profiles
as
$profile
)
{
$model
->
selected
=
false
;
$profile
->
selected
=
false
;
$model
->
save
();
$profile
->
status
=
UserType
::
STATUS_ATIVO
;
});
$profile
->
save
();
}
$profile
=
UserType
::
whereId
(
$user_type_id
)
->
first
();
$profile
=
UserType
::
whereId
(
$user_type_id
)
->
first
();
$profile
->
selected
=
true
;
$profile
->
selected
=
true
;
$profile
->
status
=
UserType
::
STATUS_ATIVO
;
$profile
->
save
();
$profile
->
save
();
return
redirect
(
'dashboard'
);
return
redirect
(
'dashboard'
);
...
...
app/Models/User.php
View file @
fb75ebce
...
@@ -183,9 +183,8 @@ class User extends Authenticatable
...
@@ -183,9 +183,8 @@ class User extends Authenticatable
}
}
/** @return UserType[]|null */
/** @return UserType[]|null */
public
function
profiles
()
public
function
profiles
()
{
{
return
$this
->
hasMany
(
UserType
::
class
)
->
whereStatus
(
UserType
::
STATUS_ATIVO
);
return
$this
->
hasMany
(
UserType
::
class
)
->
whereStatus
(
Status
::
ATIVO
);
}
}
/**
/**
...
@@ -193,7 +192,19 @@ class User extends Authenticatable
...
@@ -193,7 +192,19 @@ class User extends Authenticatable
*/
*/
public
function
profileSelected
()
public
function
profileSelected
()
{
{
return
$this
->
profiles
()
->
first
();
return
$this
->
profiles
()
->
whereSelected
(
true
)
->
first
();
}
/**
* @return UserType|Null
*/
public
function
get_profile_name
()
{
$profile
=
$this
->
profiles
->
where
(
'selected'
,
true
)
->
first
();
$name
=
$profile
!==
null
?
UserType
::
listType
(
$profile
->
type
)
:
''
;
return
$name
;
}
}
/**
/**
...
@@ -231,8 +242,7 @@ class User extends Authenticatable
...
@@ -231,8 +242,7 @@ class User extends Authenticatable
/**
/**
* @return bool
* @return bool
*/
*/
public
function
isTypeEvaluator
()
public
function
isTypeEvaluator
()
{
{
return
$this
->
profileSelected
()
->
type
===
UserType
::
EVALUATOR
;
return
$this
->
profileSelected
()
->
type
===
UserType
::
EVALUATOR
;
}
}
...
...
app/Models/UserType.php
View file @
fb75ebce
...
@@ -15,6 +15,9 @@ class UserType extends Model
...
@@ -15,6 +15,9 @@ class UserType extends Model
{
{
use
SoftDeletes
;
use
SoftDeletes
;
const
STATUS_ATIVO
=
1
;
const
STATUS_INATIVO
=
2
;
const
ADMIN
=
1
;
// Administrador
const
ADMIN
=
1
;
// Administrador
const
TEACHER
=
2
;
// Professor
const
TEACHER
=
2
;
// Professor
const
DIRECTOR
=
3
;
// Diretor
const
DIRECTOR
=
3
;
// Diretor
...
...
resources/views/layouts/navigation.blade.php
View file @
fb75ebce
...
@@ -9,6 +9,10 @@
...
@@ -9,6 +9,10 @@
if(isset($menu)) {
if(isset($menu)) {
$edit_active = $menu == Menu::USER ? 'btn btn-primary btn-sm' : 'btn btn-outline-primary btn-sm';
$edit_active = $menu == Menu::USER ? 'btn btn-primary btn-sm' : 'btn btn-outline-primary btn-sm';
}
}
/** @var App\Models\User */
$user = Auth::user();
@endphp
@endphp
@if (Auth::check())
@if (Auth::check())
...
@@ -18,7 +22,9 @@
...
@@ -18,7 +22,9 @@
<div
class=
"content-user-info"
>
<div
class=
"content-user-info"
>
<div
class=
"text-center"
>
<div
class=
"text-center"
>
<div
class=
"font-medium text-base text-gray-800"
>
{{ Auth::user()->dashboardName() }}
</div>
<div
class=
"font-medium text-base text-gray-800"
>
{{ $user->dashboardName() }}
</div>
<div
class=
"font-medium text-base text-gray-800"
>
{{ "Logado : {$user->get_profile_name()}" }}
</div>
<div
class=
"mt-3"
>
<div
class=
"mt-3"
>
<a
class=
"{{ $edit_active }}"
href=
"{{ route('edit_perfil') }}"
>
<a
class=
"{{ $edit_active }}"
href=
"{{ route('edit_perfil') }}"
>
...
...
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