1 | <?php |
||
7 | trait HasPermission |
||
8 | { |
||
9 | /** |
||
10 | * Assigns the given permission to the role. |
||
11 | * |
||
12 | * @param int $permissionId |
||
13 | * @return bool |
||
14 | */ |
||
15 | public function assignPermission($permissionId = null) |
||
27 | |||
28 | /** |
||
29 | * Get related permissions. |
||
30 | * |
||
31 | * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany |
||
32 | */ |
||
33 | public function permissions() |
||
37 | |||
38 | /** |
||
39 | * Revokes the given permission from the role. |
||
40 | * |
||
41 | * @param int|null $permissionId |
||
42 | * @return bool |
||
43 | */ |
||
44 | public function revokePermission($permissionId = null) |
||
48 | |||
49 | /** |
||
50 | * Syncs the given permission(s) with the role. |
||
51 | * |
||
52 | * @param array $permissionIds |
||
53 | * @return array|bool |
||
54 | */ |
||
55 | public function syncPermissions(array $permissionIds = []) |
||
59 | |||
60 | /** |
||
61 | * Revokes all permissions from the role. |
||
62 | * |
||
63 | * @return bool |
||
64 | */ |
||
65 | public function revokeAllPermissions() |
||
69 | |||
70 | /** |
||
71 | * Checks if the role has the given permission. |
||
72 | * |
||
73 | * @param string $permission |
||
74 | * @return bool |
||
75 | */ |
||
76 | public function can($permission) |
||
90 | |||
91 | /** |
||
92 | * Get list of permissions slug. |
||
93 | * |
||
94 | * @return array |
||
95 | */ |
||
96 | public function getPermissions() |
||
100 | |||
101 | /** |
||
102 | * Check if the role has at least one of the given permissions. |
||
103 | * |
||
104 | * @param array $permission |
||
105 | * @return bool |
||
106 | */ |
||
107 | public function canAtLeast(array $permission = []) |
||
116 | } |
||
117 |
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: