1 | <?php |
||
16 | class Role extends Model |
||
17 | { |
||
18 | use HasPermission, RefreshCache; |
||
19 | |||
20 | /** @var string */ |
||
21 | protected $table = 'roles'; |
||
22 | |||
23 | /** @var array */ |
||
24 | protected $fillable = ['name', 'slug', 'description', 'system']; |
||
25 | |||
26 | /** @var array */ |
||
27 | protected $casts = [ |
||
28 | 'system' => 'bool', |
||
29 | ]; |
||
30 | |||
31 | /** |
||
32 | * Find a role by slug. |
||
33 | * |
||
34 | * @param string $slug |
||
35 | * @return \Illuminate\Database\Eloquent\Model|static |
||
36 | * @throws \Illuminate\Database\Eloquent\ModelNotFoundException |
||
37 | */ |
||
38 | public static function findBySlug(string $slug) |
||
39 | { |
||
40 | return static::query()->where('slug', $slug)->firstOrFail(); |
||
41 | } |
||
42 | |||
43 | /** |
||
44 | * Roles can belong to many users. |
||
45 | * |
||
46 | * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany |
||
47 | */ |
||
48 | public function users(): BelongsToMany |
||
53 | } |
||
54 |