Total Complexity | 11 |
Total Lines | 90 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 0 |
1 | <?php |
||
11 | class ApplicantPolicy extends BasePolicy |
||
12 | { |
||
13 | |||
14 | /** |
||
15 | * Returns true if $manager owns a job to which $applicant has applied |
||
16 | * @param Manager $manager [description] |
||
2 ignored issues
–
show
|
|||
17 | * @param Applicant $applicant [description] |
||
2 ignored issues
–
show
|
|||
18 | * @return [type] [description] |
||
19 | */ |
||
20 | protected function managerCanViewApplicant(Manager $manager, Applicant $applicant) { |
||
21 | $applicant_id = $applicant->id; |
||
22 | return JobPoster::where('manager_id', $manager->id) |
||
23 | ->whereHas('submitted_applications', function ($q) use ($applicant_id){ |
||
24 | $q->where('applicant_id', $applicant_id); |
||
25 | }) |
||
26 | ->get()->isNotEmpty(); |
||
27 | } |
||
28 | |||
29 | /** |
||
30 | * Determine whether the user can view the applicant. |
||
31 | * |
||
32 | * @param \App\Models\User $user |
||
2 ignored issues
–
show
|
|||
33 | * @param \App\Models\Applicant $applicant |
||
2 ignored issues
–
show
|
|||
34 | * @return mixed |
||
35 | */ |
||
36 | public function view(User $user, Applicant $applicant) |
||
42 | } |
||
43 | |||
44 | /** |
||
45 | * Determine whether the user can create applicants. |
||
46 | * |
||
47 | * @param \App\Models\User $user |
||
2 ignored issues
–
show
|
|||
48 | * @return mixed |
||
49 | */ |
||
50 | public function create(User $user) |
||
51 | { |
||
52 | return false; |
||
53 | } |
||
54 | |||
55 | /** |
||
56 | * Determine whether the user can update the applicant. |
||
57 | * |
||
58 | * @param \App\Models\User $user |
||
2 ignored issues
–
show
|
|||
59 | * @param \App\Models\Applicant $applicant |
||
2 ignored issues
–
show
|
|||
60 | * @return mixed |
||
61 | */ |
||
62 | public function update(User $user, Applicant $applicant) |
||
63 | { |
||
64 | return $user->user_role->name === "applicant" && |
||
65 | $applicant->user_id === $user->id; |
||
66 | } |
||
67 | |||
68 | /** |
||
69 | * Determine whether the user can delete the applicant. |
||
70 | * |
||
71 | * @param \App\Models\User $user |
||
2 ignored issues
–
show
|
|||
72 | * @param \App\Models\Applicant $applicant |
||
2 ignored issues
–
show
|
|||
73 | * @return mixed |
||
74 | */ |
||
75 | public function delete(User $user, Applicant $applicant) |
||
76 | { |
||
77 | // |
||
78 | } |
||
79 | |||
80 | /** |
||
81 | * Determine whether the user can restore the applicant. |
||
82 | * |
||
83 | * @param \App\Models\User $user |
||
2 ignored issues
–
show
|
|||
84 | * @param \App\Models\Applicant $applicant |
||
2 ignored issues
–
show
|
|||
85 | * @return mixed |
||
86 | */ |
||
87 | public function restore(User $user, Applicant $applicant) |
||
89 | // |
||
90 | } |
||
91 | |||
92 | /** |
||
93 | * Determine whether the user can permanently delete the applicant. |
||
94 | * |
||
95 | * @param \App\Models\User $user |
||
2 ignored issues
–
show
|
|||
96 | * @param \App\Models\Applicant $applicant |
||
2 ignored issues
–
show
|
|||
97 | * @return mixed |
||
98 | */ |
||
99 | public function forceDelete(User $user, Applicant $applicant) |
||
101 | // |
||
102 | } |
||
103 | } |
||
104 |