1 | <?php |
||
7 | trait HasPermissions |
||
8 | { |
||
9 | /** |
||
10 | * Get all permissions of user. |
||
11 | * |
||
12 | * @return mixed |
||
13 | */ |
||
14 | public function allPermissions() : Collection |
||
18 | |||
19 | /** |
||
20 | * Check if user has permission. |
||
21 | * |
||
22 | * @param $permission |
||
23 | * |
||
24 | * @return bool |
||
25 | */ |
||
26 | public function can(string $permission) : bool |
||
38 | |||
39 | /** |
||
40 | * Check if user has no permission. |
||
41 | * |
||
42 | * @param $permission |
||
43 | * |
||
44 | * @return bool |
||
45 | */ |
||
46 | public function cannot(string $permission) : bool |
||
50 | |||
51 | /** |
||
52 | * Check if user is administrator. |
||
53 | * |
||
54 | * @return mixed |
||
55 | */ |
||
56 | public function isAdministrator() : bool |
||
60 | |||
61 | /** |
||
62 | * Check if user is $role. |
||
63 | * |
||
64 | * @param string $role |
||
65 | * |
||
66 | * @return mixed |
||
67 | */ |
||
68 | public function isRole(string $role) : bool |
||
72 | |||
73 | /** |
||
74 | * Check if user in $roles. |
||
75 | * |
||
76 | * @param array $roles |
||
77 | * |
||
78 | * @return mixed |
||
79 | */ |
||
80 | public function inRoles(array $roles = []) : bool |
||
84 | |||
85 | /** |
||
86 | * If visible for roles. |
||
87 | * |
||
88 | * @param $roles |
||
89 | * |
||
90 | * @return bool |
||
91 | */ |
||
92 | public function visible(array $roles = []) : bool |
||
102 | |||
103 | /** |
||
104 | * Detach models from the relationship. |
||
105 | * |
||
106 | * @return void |
||
107 | */ |
||
108 | protected static function boot() |
||
118 | } |
||
119 |
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: