| Total Complexity | 9 |
| Total Lines | 37 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 7 | trait HasRole |
||
| 8 | { |
||
| 9 | // User Belongs To Many Roles |
||
| 10 | public function roles() |
||
| 11 | { |
||
| 12 | return $this->belongsToMany(Role::class)->withTimeStamps(); |
||
|
|
|||
| 13 | } |
||
| 14 | |||
| 15 | // Check is user has given role |
||
| 16 | public function hasRole($role) |
||
| 17 | { |
||
| 18 | return $this->roles->where('name', trim($role))->count() == 1 || $this->roles->where('name', 'superuser')->count() == 1 || $this->roles->where('name', 'superadmin')->count() == 1; |
||
| 19 | } |
||
| 20 | |||
| 21 | // Check if user is superadmin |
||
| 22 | public function isSuperAdmin() |
||
| 27 | } |
||
| 28 | |||
| 29 | // Check BREAD Access |
||
| 30 | public function userCanDo($model, $bread) |
||
| 44 | } |
||
| 45 | } |
||
| 46 |