| Total Complexity | 6 |
| Total Lines | 46 |
| Duplicated Lines | 0 % |
| Coverage | 85.71% |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 11 | class UserPolicy |
||
| 12 | { |
||
| 13 | use HandlesAuthorization; |
||
| 14 | use AllowTrait; |
||
|
1 ignored issue
–
show
|
|||
| 15 | |||
| 16 | /** |
||
| 17 | 22 | * Determine whether the user can create models |
|
| 18 | */ |
||
| 19 | 22 | public function create(User $user) |
|
| 20 | { |
||
| 21 | 22 | return $this->checkPermission($user, 'Manage Users'); |
|
| 22 | 22 | } |
|
| 23 | |||
| 24 | 22 | /** |
|
| 25 | * Determine whether the user can update the user profile |
||
| 26 | 22 | */ |
|
| 27 | public function update(User $user, User $model) |
||
| 28 | 11 | { |
|
| 29 | if($this->checkPermission($user, 'Manage Users')) |
||
| 30 | 11 | { |
|
| 31 | // If they user has permission to Manage Users, they cannot manage anyone with a higher role than themselves |
||
| 32 | if($user->role_id > $model->role_id) |
||
| 33 | { |
||
| 34 | return Response::deny('You cannot modify a user with higher permissions than yourself'); |
||
| 35 | } |
||
| 36 | |||
| 37 | return true; |
||
| 38 | } |
||
| 39 | |||
| 40 | return $user->user_id === $model->user_id; |
||
| 41 | } |
||
| 42 | |||
| 43 | 4 | /** |
|
| 44 | * Determine whether the user can delete the model |
||
| 45 | 4 | */ |
|
| 46 | public function delete(User $user, User $model) |
||
| 49 | } |
||
| 50 | |||
| 51 | 6 | /** |
|
| 52 | * Determine whether the user can restore the model |
||
| 53 | 6 | */ |
|
| 54 | public function restore(User $user, User $model) |
||
| 57 | } |
||
| 58 | } |
||
| 59 |