| Total Complexity | 15 |
| Total Lines | 102 |
| Duplicated Lines | 0 % |
| Coverage | 47.62% |
| Changes | 0 | ||
| 1 | <?php |
||
| 9 | class JobPolicy extends BasePolicy |
||
| 10 | { |
||
| 11 | |||
| 12 | /** |
||
| 13 | * Determine whether the user can view the job poster. |
||
| 14 | * |
||
| 15 | * @param \App\Models\User $user |
||
|
2 ignored issues
–
show
|
|||
| 16 | * @param \App\Models\JobPoster $jobPoster |
||
|
2 ignored issues
–
show
|
|||
| 17 | * @return mixed |
||
| 18 | */ |
||
| 19 | 8 | public function view(?User $user, JobPoster $jobPoster) |
|
| 27 | ); |
||
| 28 | } |
||
| 29 | |||
| 30 | /** |
||
| 31 | * Determine whether the user can create job posters. |
||
| 32 | * |
||
| 33 | * @param \App\Models\User $user |
||
|
2 ignored issues
–
show
|
|||
| 34 | * @return mixed |
||
| 35 | */ |
||
| 36 | 3 | public function create(User $user) |
|
| 40 | } |
||
| 41 | |||
| 42 | /** |
||
| 43 | * Determine whether the user can update the job poster. |
||
| 44 | * |
||
| 45 | * @param \App\Models\User $user |
||
|
2 ignored issues
–
show
|
|||
| 46 | * @param \App\Models\JobPoster $jobPoster |
||
|
2 ignored issues
–
show
|
|||
| 47 | * @return mixed |
||
| 48 | */ |
||
| 49 | 7 | public function update(User $user, JobPoster $jobPoster) |
|
| 55 | } |
||
| 56 | |||
| 57 | /** |
||
| 58 | * Determine whether the user can review applications to the job poster. |
||
| 59 | * |
||
| 60 | * @param \App\Models\User $user |
||
|
2 ignored issues
–
show
|
|||
| 61 | * @param \App\Models\JobPoster $jobPoster |
||
|
2 ignored issues
–
show
|
|||
| 62 | * @return mixed |
||
| 63 | */ |
||
| 64 | public function review(User $user, JobPoster $jobPoster) |
||
| 70 | } |
||
| 71 | |||
| 72 | |||
| 73 | /** |
||
| 74 | * Determine whether the user can delete the job poster. |
||
| 75 | * |
||
| 76 | * @param \App\Models\User $user User object making the request. |
||
| 77 | * @param \App\Models\JobPoster $jobPoster Job Poster object being acted upon. |
||
| 78 | * |
||
| 79 | * @return boolean |
||
| 80 | */ |
||
| 81 | public function delete(User $user, JobPoster $jobPoster) : bool |
||
| 82 | { |
||
| 83 | // Jobs can only be deleted when they're in the 'draft' |
||
| 84 | // state, and only by managers that created them. |
||
| 85 | return $user->user_role->name == 'manager' && |
||
| 86 | $jobPoster->manager->user->id == $user->id && |
||
| 87 | !$jobPoster->published; |
||
| 88 | } |
||
| 89 | |||
| 90 | /** |
||
| 91 | * Determine whether the user can restore the job poster. |
||
| 92 | * |
||
| 93 | * @param \App\Models\User $user |
||
|
2 ignored issues
–
show
|
|||
| 94 | * @param \App\Models\JobPoster $jobPoster |
||
|
2 ignored issues
–
show
|
|||
| 95 | * @return mixed |
||
| 96 | */ |
||
| 97 | public function restore(User $user, JobPoster $jobPoster) |
||
| 99 | // |
||
| 100 | } |
||
| 101 | |||
| 102 | /** |
||
| 103 | * Determine whether the user can permanently delete the job poster. |
||
| 104 | * |
||
| 105 | * @param \App\Models\User $user |
||
|
2 ignored issues
–
show
|
|||
| 106 | * @param \App\Models\JobPoster $jobPoster |
||
|
2 ignored issues
–
show
|
|||
| 107 | * @return mixed |
||
| 108 | */ |
||
| 109 | public function forceDelete(User $user, JobPoster $jobPoster) |
||
| 114 |