1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Policies; |
4
|
|
|
|
5
|
|
|
use App\Models\User; |
6
|
|
|
use App\Models\Applicant; |
7
|
|
|
use App\Models\JobPoster; |
8
|
|
|
use App\Policies\BasePolicy; |
9
|
|
|
use Illuminate\Support\Facades\Gate; |
10
|
|
|
|
11
|
|
|
class ApplicantPolicy extends BasePolicy |
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* Determine whether the user can view the applicant. |
15
|
|
|
* |
16
|
|
|
* @param \App\Models\User $user User object making the view request. |
17
|
|
|
* @param \App\Models\Applicant $applicant Applicant object to be viewed. |
18
|
|
|
* @return boolean |
19
|
|
|
*/ |
20
|
|
|
public function view(User $user, Applicant $applicant) |
21
|
|
|
{ |
22
|
|
|
$authApplicant = $user->isApplicant() && |
23
|
|
|
$applicant->user->is($user); |
24
|
|
|
$authManager = $user->isManager() && Gate::allows('owns-job-applicant-applied-to', $applicant); |
25
|
|
|
$authHr = $user->isHrAdvisor() && Gate::allows('claims-job-applicant-applied-to', $applicant); |
26
|
|
|
return $authApplicant || $authManager || $authHr; |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Determine whether the user can create applicants. |
31
|
|
|
* |
32
|
|
|
* @param \App\Models\User $user User object making the create request. |
33
|
|
|
* @return boolean |
34
|
|
|
*/ |
35
|
|
|
public function create(User $user) |
36
|
|
|
{ |
37
|
|
|
return false; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Determine whether the user can update the applicant. |
42
|
|
|
* |
43
|
|
|
* @param \App\Models\User $user User object making the update request. |
44
|
|
|
* @param \App\Models\Applicant $applicant Applicant object being updated. |
45
|
|
|
* @return boolean |
46
|
|
|
*/ |
47
|
|
|
public function update(User $user, Applicant $applicant) |
48
|
|
|
{ |
49
|
|
|
return $user->isApplicant() && |
50
|
|
|
$applicant->user_id === $user->id; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Determine whether the user can delete the applicant. |
55
|
|
|
* |
56
|
|
|
* @param \App\Models\User $user User object making the delete request. |
57
|
|
|
* @param \App\Models\Applicant $applicant Applicant object being deleted. |
58
|
|
|
* @return void |
59
|
|
|
*/ |
60
|
|
|
public function delete(User $user, Applicant $applicant) |
61
|
|
|
{ |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* Determine whether the user can restore the applicant. |
66
|
|
|
* |
67
|
|
|
* @param \App\Models\User $user User object making the restore request. |
68
|
|
|
* @param \App\Models\Applicant $applicant Applicant object being restored. |
69
|
|
|
* @return void |
70
|
|
|
*/ |
71
|
|
|
public function restore(User $user, Applicant $applicant) |
72
|
|
|
{ |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* Determine whether the user can permanently delete the applicant. |
77
|
|
|
* |
78
|
|
|
* @param \App\Models\User $user User object making the forceDelete request. |
79
|
|
|
* @param \App\Models\Applicant $applicant Applicant object being forceDeleted. |
80
|
|
|
* @return void |
81
|
|
|
*/ |
82
|
|
|
public function forceDelete(User $user, Applicant $applicant) |
83
|
|
|
{ |
84
|
|
|
} |
85
|
|
|
} |
86
|
|
|
|