| Total Complexity | 6 | 
| Total Lines | 69 | 
| Duplicated Lines | 0 % | 
| Coverage | 0% | 
| Changes | 0 | ||
| 1 | <?php | ||
| 8 | class UserPolicy | ||
| 9 | { | ||
| 10 | use HandlesAuthorization; | ||
| 11 | |||
| 12 | /** | ||
| 13 | * The before method will be executed before any other methods on the policy, | ||
| 14 | * giving you an opportunity to authorize the action before the intended | ||
| 15 | * policy method is actually called. This feature is most commonly used for | ||
| 16 | * authorizing application administrators to perform any action. | ||
| 17 | */ | ||
| 18 | public function before($user, $ability) | ||
| 19 |     { | ||
| 20 | // TODO: Admins... | ||
| 21 |         // if ($user->isSuperAdmin()) { | ||
| 22 | // return true; | ||
| 23 | // } | ||
| 24 | return false; | ||
| 25 | } | ||
| 26 | |||
| 27 | /** | ||
| 28 | * Determine whether the user can view the user. | ||
| 29 | * | ||
| 30 | * @param \App\User $user | ||
| 31 | * @param \App\User $user | ||
| 32 | * @return boolean | ||
| 33 | */ | ||
| 34 | public function view(User $user, User $user2) | ||
| 35 |     { | ||
| 36 | // TODO: Check if user role is > 0 | ||
| 37 | return $user->role > 1 || $user->id === $user2->id; | ||
| 38 | } | ||
| 39 | |||
| 40 | /** | ||
| 41 | * Determine whether the user can create users. | ||
| 42 | * | ||
| 43 | * @param \App\User $user | ||
| 44 | * @return boolean | ||
| 45 | */ | ||
| 46 | public function create(User $user) | ||
| 47 |     { | ||
| 48 | // TODO: Check if user role > 1 | ||
| 49 | return true; | ||
| 50 | } | ||
| 51 | |||
| 52 | /** | ||
| 53 | * Determine whether the user can update the user2. | ||
| 54 | * | ||
| 55 | * @param \App\User $user | ||
| 56 | * @param \App\User $user | ||
| 57 | * @return boolean | ||
| 58 | */ | ||
| 59 | public function update(User $user, User $user2) | ||
| 60 |     { | ||
| 61 | // Users can update themselves | ||
| 62 | //return $user->id === $user->id; | ||
| 63 | return true; | ||
| 64 | } | ||
| 65 | |||
| 66 | /** | ||
| 67 | * Determine whether the user can delete the user. | ||
| 68 | * | ||
| 69 | * @param \App\User $user | ||
| 70 | * @param \App\User $user | ||
| 71 | * @return boolean | ||
| 72 | */ | ||
| 73 | public function delete(User $user, User $user2) | ||
| 77 | } | ||
| 78 | } | ||
| 79 | 
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.