|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Providers; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Support\Facades\Auth; |
|
6
|
|
|
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider; |
|
7
|
|
|
use Illuminate\Support\Facades\Gate; |
|
8
|
|
|
use App\Models\Applicant; |
|
9
|
|
|
use App\Models\Course; |
|
10
|
|
|
use App\Models\Degree; |
|
11
|
|
|
use App\Models\Manager; |
|
12
|
|
|
use App\Models\JobPoster; |
|
13
|
|
|
use App\Models\Reference; |
|
14
|
|
|
use App\Models\WorkSample; |
|
15
|
|
|
use App\Models\JobApplication; |
|
16
|
|
|
use App\Models\WorkExperience; |
|
17
|
|
|
use App\Models\SkillDeclaration; |
|
18
|
|
|
use App\Policies\JobPolicy; |
|
19
|
|
|
use App\Policies\CoursePolicy; |
|
20
|
|
|
use App\Policies\DegreePolicy; |
|
21
|
|
|
use App\Policies\ManagerPolicy; |
|
22
|
|
|
use App\Policies\ApplicantPolicy; |
|
23
|
|
|
use App\Policies\ReferencePolicy; |
|
24
|
|
|
use App\Policies\ApplicationPolicy; |
|
25
|
|
|
use App\Policies\SkillDeclarationPolicy; |
|
26
|
|
|
use App\Policies\WorkExperiencePolicy; |
|
27
|
|
|
use App\Policies\WorkSamplePolicy; |
|
28
|
|
|
|
|
29
|
|
|
class AuthServiceProvider extends ServiceProvider |
|
30
|
|
|
{ |
|
31
|
|
|
/** |
|
32
|
|
|
* The policy mappings for the application. |
|
33
|
|
|
* |
|
34
|
|
|
* @var array |
|
|
|
|
|
|
35
|
|
|
*/ |
|
36
|
|
|
protected $policies = [ |
|
37
|
|
|
Applicant::class => ApplicantPolicy::class, |
|
38
|
|
|
Manager::class => ManagerPolicy::class, |
|
39
|
|
|
JobPoster::class => JobPolicy::class, |
|
40
|
|
|
JobApplication::class => ApplicationPolicy::class, |
|
41
|
|
|
Course::class => CoursePolicy::class, |
|
42
|
|
|
Degree::class => DegreePolicy::class, |
|
43
|
|
|
Reference::class => ReferencePolicy::class, |
|
44
|
|
|
SkillDeclaration::class => SkillDeclarationPolicy::class, |
|
45
|
|
|
WorkExperience::class => WorkExperiencePolicy::class, |
|
46
|
|
|
WorkSample::class => WorkSamplePolicy::class |
|
47
|
|
|
]; |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* Define any authorization gates |
|
51
|
|
|
* |
|
52
|
|
|
* @return void |
|
53
|
|
|
*/ |
|
54
|
73 |
|
protected function defineGates(): void |
|
55
|
|
|
{ |
|
56
|
|
|
Gate::define('view-assessment-plan', function ($user, $jobPoster) { |
|
57
|
|
|
return $user->hasRole('admin') || |
|
58
|
|
|
$user->hasRole('manager') && $jobPoster->manager->user_id === $user->id; |
|
59
|
73 |
|
}); |
|
60
|
73 |
|
} |
|
61
|
|
|
|
|
62
|
73 |
|
public function register(): void |
|
|
|
|
|
|
63
|
|
|
{ |
|
64
|
73 |
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* Register any authentication / authorization services. |
|
68
|
|
|
* |
|
69
|
|
|
* @return void |
|
70
|
|
|
*/ |
|
71
|
73 |
|
public function boot(): void |
|
72
|
|
|
{ |
|
73
|
73 |
|
$this->registerPolicies(); |
|
74
|
|
|
|
|
75
|
73 |
|
$this->defineGates(); |
|
76
|
73 |
|
} |
|
77
|
|
|
} |
|
78
|
|
|
|