| 1 | <?php |
||
| 10 | class Role extends Model |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * @var array |
||
| 14 | */ |
||
| 15 | protected $casts = ['permissions' => 'json']; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * @var array |
||
| 19 | */ |
||
| 20 | protected $hidden = ['deleted_at']; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * @var array |
||
| 24 | */ |
||
| 25 | protected $fillable = [ |
||
| 26 | 'name', |
||
| 27 | 'description', |
||
| 28 | 'is_default', |
||
| 29 | 'permissions', |
||
| 30 | 'slug', |
||
| 31 | 'access_level', |
||
| 32 | 'access_level_parent', |
||
| 33 | ]; |
||
| 34 | |||
| 35 | /** |
||
| 36 | * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany |
||
| 37 | */ |
||
| 38 | 2 | public function users() |
|
| 39 | { |
||
| 40 | 2 | return $this->belongsToMany(config('acl.models.user'), config('acl.table_names.users_roles')); |
|
| 41 | } |
||
| 42 | |||
| 43 | /** |
||
| 44 | * @throws \Exception |
||
| 45 | * |
||
| 46 | * @return bool |
||
| 47 | */ |
||
| 48 | 2 | public function delete() |
|
| 54 | |||
| 55 | /** |
||
| 56 | * @return array |
||
| 57 | */ |
||
| 58 | 34 | public function getPermissions() |
|
| 62 | |||
| 63 | /** |
||
| 64 | * @param null|array $permissions |
||
| 65 | * |
||
| 66 | * @throws \InvalidArgumentException |
||
| 67 | * |
||
| 68 | * @return void |
||
| 69 | */ |
||
| 70 | 2 | public function setPermissionsAttribute(?array $permissions) |
|
| 80 | } |
||
| 81 |