Misc unrelated updates
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (push) Has been cancelled
tests / ui (push) Has been cancelled

This commit is contained in:
Codex Agent
2026-01-12 10:31:31 +01:00
parent e9afbeb028
commit 3de1d3deab
40 changed files with 433 additions and 267 deletions

View File

@@ -69,6 +69,16 @@ class User extends Authenticatable implements FilamentHasTenants, FilamentUser,
];
}
public function isSuperAdmin(): bool
{
return self::isSuperAdminRole($this->role);
}
public static function isSuperAdminRole(?string $role): bool
{
return in_array($role, ['super_admin', 'superadmin'], true);
}
/**
* Retrieve the user by the given credentials.
*/
@@ -127,12 +137,12 @@ class User extends Authenticatable implements FilamentHasTenants, FilamentUser,
public function canAccessPanel(Panel $panel): bool
{
if (! $this->email_verified_at && $this->role !== 'super_admin') {
if (! $this->email_verified_at && ! $this->isSuperAdmin()) {
return false;
}
return match ($panel->getId()) {
'superadmin' => $this->role === 'super_admin',
'superadmin' => $this->isSuperAdmin(),
'admin' => $this->role === 'tenant_admin',
default => false,
};
@@ -140,7 +150,7 @@ class User extends Authenticatable implements FilamentHasTenants, FilamentUser,
public function canAccessTenant(Model $tenant): bool
{
if ($this->role === 'super_admin') {
if ($this->isSuperAdmin()) {
return true;
}
@@ -155,7 +165,7 @@ class User extends Authenticatable implements FilamentHasTenants, FilamentUser,
public function getTenants(Panel $panel): array|Collection
{
if ($this->role === 'super_admin') {
if ($this->isSuperAdmin()) {
return Tenant::query()->orderBy('name')->get();
}