1 | <?php |
||
12 | trait Administrable |
||
13 | { |
||
14 | /** |
||
15 | * New filled roles. |
||
16 | * |
||
17 | * @var array |
||
18 | */ |
||
19 | private $_roles; |
||
20 | |||
21 | /** |
||
22 | * @var int|null |
||
23 | */ |
||
24 | private $_countAdministrativeRoles; |
||
25 | |||
26 | /** |
||
27 | * User identifier. |
||
28 | * |
||
29 | * @return int |
||
30 | */ |
||
31 | public function getIdAttribute(): int |
||
35 | |||
36 | /** |
||
37 | * User name. |
||
38 | * |
||
39 | * @return string |
||
40 | */ |
||
41 | public function getNameAttribute(): string |
||
45 | |||
46 | /** |
||
47 | * Set new filled roles. |
||
48 | * |
||
49 | * @param $value |
||
50 | * |
||
51 | * @return void |
||
52 | */ |
||
53 | public function setRolesAttribute($value): void |
||
57 | |||
58 | /** |
||
59 | * Get user roles by relation. |
||
60 | * |
||
61 | * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany |
||
62 | */ |
||
63 | public function roles() |
||
67 | |||
68 | /** |
||
69 | * Checks if User has access to $permissions. |
||
70 | * |
||
71 | * @param array $permissions |
||
72 | * |
||
73 | * @return bool |
||
74 | */ |
||
75 | public function hasAccess(array $permissions) : bool |
||
87 | |||
88 | /** |
||
89 | * Checks if the user belongs to role. |
||
90 | * |
||
91 | * @param string $roleSlug |
||
92 | * |
||
93 | * @return bool |
||
94 | */ |
||
95 | public function inRole(string $roleSlug): bool |
||
99 | |||
100 | /** |
||
101 | * Can assign role checking. |
||
102 | * |
||
103 | * @param RbacUserContract $member |
||
104 | * @param Role $role |
||
105 | * |
||
106 | * @return bool |
||
107 | */ |
||
108 | public function canAssignRole(RbacUserContract $member, Role $role): bool |
||
132 | |||
133 | /** |
||
134 | * Synchronize user roles after save model. |
||
135 | * |
||
136 | * @param array $options |
||
137 | * |
||
138 | * @return bool |
||
139 | */ |
||
140 | public function save(array $options = []) |
||
152 | |||
153 | /** |
||
154 | * @return int |
||
155 | */ |
||
156 | private function countAdministrativeRoles(): int |
||
174 | } |
||
175 |
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: