Misc unrelated updates
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user