1 | <?php namespace Arcanesoft\Auth\Models; |
||
21 | class Role extends BaseRole |
||
22 | { |
||
23 | /* ----------------------------------------------------------------- |
||
24 | | Constants |
||
25 | | ----------------------------------------------------------------- |
||
26 | */ |
||
27 | |||
28 | const ADMINISTRATOR = 'administrator'; |
||
29 | const MODERATOR = 'moderator'; |
||
30 | const MEMBER = 'member'; |
||
31 | |||
32 | /* ----------------------------------------------------------------- |
||
33 | | Traits |
||
34 | | ----------------------------------------------------------------- |
||
35 | */ |
||
36 | |||
37 | use Presenters\RolePresenter; |
||
38 | |||
39 | /* ----------------------------------------------------------------- |
||
40 | | Relationships |
||
41 | | ----------------------------------------------------------------- |
||
42 | */ |
||
43 | |||
44 | /** |
||
45 | * Role belongs to many users. |
||
46 | * |
||
47 | * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany |
||
48 | */ |
||
49 | public function users() |
||
53 | |||
54 | /* ----------------------------------------------------------------- |
||
55 | | Scopes |
||
56 | | ----------------------------------------------------------------- |
||
57 | */ |
||
58 | |||
59 | /** |
||
60 | * Scope only with administrator role. |
||
61 | * |
||
62 | * @param \Illuminate\Database\Eloquent\Builder $query |
||
63 | * |
||
64 | * @return \Illuminate\Database\Eloquent\Builder |
||
65 | */ |
||
66 | public function scopeAdmin(Builder $query) |
||
70 | |||
71 | /** |
||
72 | * Scope only with moderator role. |
||
73 | * |
||
74 | * @param \Illuminate\Database\Eloquent\Builder $query |
||
75 | * |
||
76 | * @return \Illuminate\Database\Eloquent\Builder |
||
77 | */ |
||
78 | public function scopeModerator(Builder $query) |
||
82 | |||
83 | /** |
||
84 | * Scope only with member role. |
||
85 | * |
||
86 | * @param \Illuminate\Database\Eloquent\Builder $query |
||
87 | * |
||
88 | * @return \Illuminate\Database\Eloquent\Builder |
||
89 | */ |
||
90 | public function scopeMember(Builder $query) |
||
94 | |||
95 | /* ----------------------------------------------------------------- |
||
96 | | Main Methods |
||
97 | | ----------------------------------------------------------------- |
||
98 | */ |
||
99 | |||
100 | /** |
||
101 | * Get a role from a hashed id or fail if not found. |
||
102 | * |
||
103 | * @param string $hashedId |
||
104 | * |
||
105 | * @return self |
||
106 | * |
||
107 | * @throws \Illuminate\Database\Eloquent\ModelNotFoundException |
||
108 | */ |
||
109 | public static function firstHashedOrFail($hashedId) |
||
113 | |||
114 | /** |
||
115 | * Make the slug. |
||
116 | * |
||
117 | * @param string $value |
||
118 | * |
||
119 | * @return string |
||
120 | */ |
||
121 | public function makeSlugName($value) |
||
125 | } |
||
126 |