Applied API role specs to short URL creation

This commit is contained in:
Alejandro Celaya
2021-01-04 20:15:42 +01:00
parent 19834f6715
commit 4b67d41362
15 changed files with 314 additions and 7 deletions

View File

@@ -83,4 +83,11 @@ class ApiKey extends AbstractEntity
{
return $this->roles->exists(fn ($key, ApiKeyRole $role) => $role->name() === $roleName);
}
public function getRoleMeta(string $roleName): array
{
/** @var ApiKeyRole|false $role */
$role = $this->roles->filter(fn (ApiKeyRole $role) => $role->name() === $roleName)->first();
return ! $role ? [] : $role->meta();
}
}