1 | <?php |
||
13 | trait Administrable |
||
14 | { |
||
15 | /** |
||
16 | * New filled roles. |
||
17 | * |
||
18 | * @var array |
||
19 | */ |
||
20 | private $_roles; |
||
21 | |||
22 | /** |
||
23 | * @var int|null |
||
24 | */ |
||
25 | private $_countAdministrativeRoles; |
||
26 | |||
27 | /** |
||
28 | * User identifier. |
||
29 | * @return mixed |
||
30 | */ |
||
31 | public function getMemberKeyAttribute() |
||
35 | |||
36 | /** |
||
37 | * @return string |
||
38 | */ |
||
39 | public function getMemberNameAttribute(): string |
||
57 | |||
58 | /** |
||
59 | * Set new filled roles. |
||
60 | * @param $value |
||
61 | * @return void |
||
62 | */ |
||
63 | public function setRolesAttribute($value): void |
||
67 | |||
68 | /** |
||
69 | * Get user roles by relation. |
||
70 | * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany |
||
71 | */ |
||
72 | public function roles() |
||
76 | |||
77 | /** |
||
78 | * Checks if User has access to $permissions. |
||
79 | * @param array $permissions |
||
80 | * @return bool |
||
81 | */ |
||
82 | public function hasAccess(array $permissions) : bool |
||
94 | |||
95 | /** |
||
96 | * Checks if the user belongs to role. |
||
97 | * @param string $roleSlug |
||
98 | * @return bool |
||
99 | */ |
||
100 | public function inRole(string $roleSlug): bool |
||
104 | |||
105 | /** |
||
106 | * Can assign role checking. |
||
107 | * @param RbacUserInterface $member |
||
108 | * @param Role $role |
||
109 | * @return bool |
||
110 | */ |
||
111 | public function canAssignRole(RbacUserInterface $member, Role $role): bool |
||
135 | |||
136 | /** |
||
137 | * Synchronize user roles after save model. |
||
138 | * @param array $options |
||
139 | * @return bool |
||
140 | */ |
||
141 | public function save(array $options = []) |
||
153 | |||
154 | /** |
||
155 | * @return int |
||
156 | */ |
||
157 | private function countAdministrativeRoles(): int |
||
175 | } |
||
176 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: