Applied API role specs to tag visits

This commit is contained in:
Alejandro Celaya
2021-01-04 11:14:28 +01:00
parent 4a1e7b761a
commit 8aa6bdb934
17 changed files with 214 additions and 37 deletions

View File

@@ -68,9 +68,14 @@ class ApiKey extends AbstractEntity
return $this->key;
}
public function spec(): Specification
public function spec(bool $inlined = false): Specification
{
$specs = $this->roles->map(fn (ApiKeyRole $role) => Role::toSpec($role));
$specs = $this->roles->map(fn (ApiKeyRole $role) => Role::toSpec($role, $inlined));
return Spec::andX(...$specs);
}
public function isAdmin(): bool
{
return $this->roles->count() === 0;
}
}