@@ 212-217 (lines=6) @@ | ||
209 | */ |
|
210 | public function hasPermissionTo($permission, $guardName = null): bool |
|
211 | { |
|
212 | if (is_string($permission)) { |
|
213 | $permission = app(Permission::class)->findByName( |
|
214 | $permission, |
|
215 | $guardName ?? $this->getDefaultGuardName() |
|
216 | ); |
|
217 | } |
|
218 | ||
219 | return $this->hasDirectPermission($permission) || $this->hasPermissionViaRole($permission); |
|
220 | } |
|
@@ 265-271 (lines=7) @@ | ||
262 | */ |
|
263 | public function hasDirectPermission($permission): bool |
|
264 | { |
|
265 | if (is_string($permission)) { |
|
266 | $permission = app(Permission::class)->findByName($permission, $this->getDefaultGuardName()); |
|
267 | ||
268 | if (! $permission) { |
|
269 | return false; |
|
270 | } |
|
271 | } |
|
272 | ||
273 | return $this->permissions->contains('id', $permission->id); |
|
274 | } |