1 | <?php |
||
9 | trait RoleHasRelations |
||
10 | { |
||
11 | /** |
||
12 | * Role belongs to many permissions. |
||
13 | * |
||
14 | * @return BelongsToMany |
||
15 | */ |
||
16 | public function permissions() |
||
20 | |||
21 | /** |
||
22 | * Role belongs to many users. |
||
23 | * |
||
24 | * @return BelongsToMany |
||
25 | */ |
||
26 | public function users() |
||
30 | |||
31 | /** |
||
32 | * Attach permission to a role. |
||
33 | * |
||
34 | * @param int|Permission $permission |
||
35 | * @return int|bool |
||
36 | */ |
||
37 | public function attachPermission($permission) |
||
41 | |||
42 | /** |
||
43 | * Detach permission from a role. |
||
44 | * |
||
45 | * @param int|Permission $permission |
||
46 | * @return int |
||
47 | */ |
||
48 | public function detachPermission($permission) |
||
52 | |||
53 | /** |
||
54 | * Detach all permissions. |
||
55 | * |
||
56 | * @return int |
||
57 | */ |
||
58 | public function detachAllPermissions() |
||
62 | |||
63 | /** |
||
64 | * Sync permissions for a role. |
||
65 | * |
||
66 | * @param array|Permission[]|Collection $permissions |
||
67 | * @return array |
||
68 | */ |
||
69 | public function syncPermissions($permissions) |
||
73 | } |
||
74 |
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idable
provides a methodequalsId
that in turn relies on the methodgetId()
. If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()
as an abstract method to the trait will make sure it is available.