Skip to content

Commit 573d692

Browse files
committed
Permissions: Fixed check method to allow enum usage
1 parent 419dbad commit 573d692

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

app/Permissions/PermissionApplicator.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,13 @@ protected function hasEntityPermission(Entity $entity, array $userRoleIds, strin
7676
* Checks if a user has the given permission for any items in the system.
7777
* Can be passed an entity instance to filter on a specific type.
7878
*/
79-
public function checkUserHasEntityPermissionOnAny(string $action, string $entityClass = ''): bool
79+
public function checkUserHasEntityPermissionOnAny(string|Permission $action, string $entityClass = ''): bool
8080
{
81-
$this->ensureValidEntityAction($action);
81+
$permissionName = is_string($action) ? $action : $action->value;
82+
$this->ensureValidEntityAction($permissionName);
8283

8384
$permissionQuery = EntityPermission::query()
84-
->where($action, '=', true)
85+
->where($permissionName, '=', true)
8586
->whereIn('role_id', $this->getCurrentUserRoleIds());
8687

8788
if (!empty($entityClass)) {

0 commit comments

Comments
 (0)