Add logic to update user's chief role

This commit is contained in:
Matteo Gheza 2024-01-09 17:21:15 +01:00
parent 37b7951b64
commit 2bd9ecaacf
1 changed files with 11 additions and 0 deletions

View File

@ -171,6 +171,17 @@ class UserController extends Controller
if(!$canBan) $request->request->remove('banned');
if(!$canHide) $request->request->remove('hidden');
//Check if chief attribute is present and changed from previous value
if($request->has('chief') && $request->chief != $user->chief) {
if($request->chief) {
//Add role chief to the user
$user->addRole('chief');
} else {
//Remove role chief from the user
$user->removeRole('chief');
}
}
$user->update($request->all());
if($request->has('birthday')) {