akubiczek /
applicake-backend
| 1 | <?php |
||||
| 2 | |||||
| 3 | namespace App\Policies; |
||||
| 4 | |||||
| 5 | use App\Models\Candidate; |
||||
| 6 | use App\Models\User; |
||||
| 7 | use Illuminate\Auth\Access\HandlesAuthorization; |
||||
| 8 | |||||
| 9 | class CandidatePolicy |
||||
| 10 | { |
||||
| 11 | use HandlesAuthorization; |
||||
| 12 | |||||
| 13 | public function view(User $user, Candidate $candidate) |
||||
| 14 | { |
||||
| 15 | if ($user->can('read all recruitments')) { |
||||
| 16 | return true; |
||||
| 17 | } |
||||
| 18 | |||||
| 19 | if ($user->grantedRecruitments->contains($candidate->recruitment->id)) { |
||||
| 20 | return true; |
||||
| 21 | } |
||||
| 22 | |||||
| 23 | return false; |
||||
| 24 | } |
||||
| 25 | |||||
| 26 | public function delete(User $user, Candidate $candidate) |
||||
|
0 ignored issues
–
show
|
|||||
| 27 | { |
||||
| 28 | if ($user->can('update any recruitment')) { |
||||
| 29 | return true; |
||||
| 30 | } |
||||
| 31 | |||||
| 32 | return false; |
||||
| 33 | } |
||||
| 34 | |||||
| 35 | public function create(User $user) |
||||
| 36 | { |
||||
| 37 | if ($user->can('create candidates')) { |
||||
| 38 | return true; |
||||
| 39 | } |
||||
| 40 | |||||
| 41 | return false; |
||||
| 42 | } |
||||
| 43 | |||||
| 44 | public function update(User $user, Candidate $candidate) |
||||
| 45 | { |
||||
| 46 | if ($user->can('update any recruitment')) { |
||||
| 47 | return true; |
||||
| 48 | } |
||||
| 49 | |||||
| 50 | if ($user->grantedRecruitments->contains($candidate->recruitment->id)) { |
||||
| 51 | return true; |
||||
| 52 | } |
||||
| 53 | |||||
| 54 | return false; |
||||
| 55 | } |
||||
| 56 | |||||
| 57 | public function changeStage(User $user) |
||||
| 58 | { |
||||
| 59 | if ($user->can('update any recruitment')) { |
||||
| 60 | return true; |
||||
| 61 | } |
||||
| 62 | |||||
| 63 | $candidate = Candidate::findOrFail(request()->get('candidate_id')); |
||||
|
0 ignored issues
–
show
The method
get() does not exist on Illuminate\Http\Request.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. Loading history...
|
|||||
| 64 | if ($user->grantedRecruitments->contains($candidate->recruitment->id)) { |
||||
|
0 ignored issues
–
show
|
|||||
| 65 | return true; |
||||
| 66 | } |
||||
| 67 | |||||
| 68 | return false; |
||||
| 69 | } |
||||
| 70 | } |
||||
| 71 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.