@@ 59-70 (lines=12) @@ | ||
56 | /** |
|
57 | * A permission belongs to some users of the model associated with its guard. |
|
58 | */ |
|
59 | public function users(): MorphToMany |
|
60 | { |
|
61 | $permissionsForeignKeyName = str_singular(config('permission.table_names.permissions')).'_id'; |
|
62 | ||
63 | return $this->morphedByMany( |
|
64 | getModelForGuard($this->attributes['guard_name']), |
|
65 | 'model', |
|
66 | config('permission.table_names.model_has_permissions'), |
|
67 | $permissionsForeignKeyName, |
|
68 | 'model_id' |
|
69 | ); |
|
70 | } |
|
71 | ||
72 | /** |
|
73 | * Find a permission by its name (and optionally guardName). |
@@ 60-70 (lines=11) @@ | ||
57 | /** |
|
58 | * A role belongs to some users of the model associated with its guard. |
|
59 | */ |
|
60 | public function users(): MorphToMany |
|
61 | { |
|
62 | $rolesForeignKeyName = str_singular(config('permission.table_names.roles')).'_id'; |
|
63 | ||
64 | return $this->morphedByMany( |
|
65 | getModelForGuard($this->attributes['guard_name']), |
|
66 | 'model', |
|
67 | config('permission.table_names.model_has_roles'), |
|
68 | $rolesForeignKeyName, |
|
69 | 'model_id' |
|
70 | ); |
|
71 | } |
|
72 | ||
73 | /** |