From 9056ee131f3b58554f0567170910f51bbbc0e87e Mon Sep 17 00:00:00 2001 From: miguel456 Date: Fri, 21 Oct 2022 15:06:00 +0100 Subject: [PATCH] refactor: update user roles and permissions for new role Signed-off-by: miguel456 --- app/Listeners/PromoteUser.php | 8 ++++++-- database/seeders/PermissionSeeder.php | 15 +++++++++++---- resources/views/home.blade.php | 2 +- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/app/Listeners/PromoteUser.php b/app/Listeners/PromoteUser.php index e53493b..93675cd 100755 --- a/app/Listeners/PromoteUser.php +++ b/app/Listeners/PromoteUser.php @@ -45,11 +45,15 @@ class PromoteUser */ public function handle(ApplicationApprovedEvent $event) { - Log::info('User '.$event->application->user->name . 'has just been promoted (application approved)'); + Log::info('User promoted automatically (application approved)', [ + 'user' => $event->application->user->name, + 'vacancy' => $event->application->response->vacancy->vacancyName, + 'role' => 'staff' + ]); $event->application->setStatus('APPROVED'); $event->application->response->vacancy->decrease(); - $event->application->user->assignRole('reviewer'); + $event->application->user->assignRole('staff'); $event->application->user->notify(new ApplicationApproved($event->application)); } diff --git a/database/seeders/PermissionSeeder.php b/database/seeders/PermissionSeeder.php index 03c6118..4decf3a 100755 --- a/database/seeders/PermissionSeeder.php +++ b/database/seeders/PermissionSeeder.php @@ -42,6 +42,10 @@ class PermissionSeeder extends Seeder ] ); + $staff = Role::create([ + 'name' => 'staff' + ]); + $reviewer = Role::create( [ 'name' => 'reviewer' @@ -108,15 +112,18 @@ class PermissionSeeder extends Seeder 'profiles.view.others' ]); - // Able to view applications and vote on them once they reach the right stage, but not approve applications up to said stage - $reviewer->givePermissionTo([ - 'applications.view.all', - 'applications.vote', + $staff->givePermissionTo([ 'reviewer.viewAbsence', 'reviewer.requestAbsence', 'reviewer.withdrawAbsence', ]); + // Able to view applications and vote on them once they reach the right stage, but not approve applications up to said stage + $reviewer->givePermissionTo([ + 'applications.view.all', + 'applications.vote' + ]); + $hiringManager->givePermissionTo('appointments.*', 'applications.*', 'admin.hiring.*'); $admin->givePermissionTo([ diff --git a/resources/views/home.blade.php b/resources/views/home.blade.php index 1721ac5..223b2bd 100755 --- a/resources/views/home.blade.php +++ b/resources/views/home.blade.php @@ -25,7 +25,7 @@ {!! $position->vacancyFullDescription !!}

- {{__('Last updated :lastUpdatedTimeValue', ['lastUpdatedTimeValue' => $position->updated_at->diffForHumans()])}} + {{__('Last updated :lastUpdatedRelativeTimeValue', ['lastUpdatedRelativeTimeValue' => $position->updated_at->diffForHumans()])}}

@endif