diff --git a/src/Commands/SuperAdminCommand.php b/src/Commands/SuperAdminCommand.php index 87957a1..4bddaf7 100644 --- a/src/Commands/SuperAdminCommand.php +++ b/src/Commands/SuperAdminCommand.php @@ -85,7 +85,7 @@ public function handle(): int $this->superAdmin = $this->createSuperAdmin(); } - if (Utils::isTeamFeatureEnabled()) { + if (Utils::isTenancyEnabled()) { if (blank($tenantId)) { $this->components->error('Please provide the team/tenant id via `--tenant` option to assign the super admin to a team/tenant.'); diff --git a/src/Concerns/HasAboutCommand.php b/src/Concerns/HasAboutCommand.php index 6263c73..420f887 100644 --- a/src/Concerns/HasAboutCommand.php +++ b/src/Concerns/HasAboutCommand.php @@ -20,8 +20,8 @@ public function initAboutCommand() // 'Resource Sort' => Utils::getResourceNavigationSort(), // 'Resource Badge' => Utils::isResourceNavigationBadgeEnabled() ? 'ENABLED' : 'DISABLED', // 'Resource Group' => Utils::isResourceNavigationGroupEnabled() ? 'ENABLED' : 'DISABLED', - 'Tenancy' => Utils::isTeamFeatureEnabled() ? 'ENABLED' : 'DISABLED', - 'Tenant Model' => Utils::isTeamFeatureEnabled() && filled($model = config()->get('filament-shield.tenant_model')) ? $model : null, + 'Tenancy' => Utils::isTenancyEnabled() ? 'ENABLED' : 'DISABLED', + 'Tenant Model' => Utils::isTenancyEnabled() && filled($model = config()->get('filament-shield.tenant_model')) ? $model : null, 'Translations' => is_dir(resource_path('resource/lang/vendor/filament-shield')) ? 'PUBLISHED' : 'NOT PUBLISHED', 'Views' => is_dir(resource_path('views/vendor/filament-shield')) ? 'PUBLISHED' : 'NOT PUBLISHED', 'Version' => InstalledVersions::getPrettyVersion('bezhansalleh/filament-shield'), diff --git a/src/FilamentShield.php b/src/FilamentShield.php index 25f78a3..5b1dc34 100755 --- a/src/FilamentShield.php +++ b/src/FilamentShield.php @@ -108,7 +108,7 @@ protected static function giveSuperAdminPermission(string | array | Collection $ public static function createRole(?string $name = null, ?int $tenantId = null): Role { - if (Utils::isTeamFeatureEnabled()) { + if (Utils::isTenancyEnabled()) { return Utils::getRoleModel()::firstOrCreate( [ 'name' => $name ?? Utils::getSuperAdminName(), diff --git a/src/Resources/RoleResource.php b/src/Resources/RoleResource.php index 067307d..8a3dbe0 100644 --- a/src/Resources/RoleResource.php +++ b/src/Resources/RoleResource.php @@ -61,9 +61,8 @@ public static function form(Form $form): Form /** @phpstan-ignore-next-line */ ->default([Filament::getTenant()?->id]) ->options(fn (): Arrayable => Utils::getTenantModel() ? Utils::getTenantModel()::pluck('name', 'id') : collect()) - ->hidden(fn (): bool => ! static::shield()->isCentralApp() && Filament::hasTenancy()) - ->dehydrated(fn (): bool => ! static::shield()->isCentralApp() && Filament::hasTenancy()), - + ->hidden(fn (): bool => ! (static::shield()->isCentralApp() && Utils::isTenancyEnabled())) + ->dehydrated(fn (): bool => ! (static::shield()->isCentralApp() && Utils::isTenancyEnabled())), ShieldSelectAllToggle::make('select_all') ->onIcon('heroicon-s-shield-check') ->offIcon('heroicon-s-shield-exclamation') @@ -100,7 +99,7 @@ public static function table(Table $table): Table ->color(fn (mixed $state): string => str($state)->contains('Global') ? 'gray' : 'primary') ->label(__('filament-shield::filament-shield.column.team')) ->searchable() - ->visible(fn (): bool => static::shield()->isCentralApp() && ! Filament::hasTenancy()), + ->visible(fn (): bool => static::shield()->isCentralApp() && Utils::isTenancyEnabled()), Tables\Columns\TextColumn::make('permissions_count') ->badge() ->label(__('filament-shield::filament-shield.column.permissions')) diff --git a/src/Support/Utils.php b/src/Support/Utils.php index f13cc8c..3b95ad4 100644 --- a/src/Support/Utils.php +++ b/src/Support/Utils.php @@ -262,7 +262,7 @@ protected static function isRolePolicyGenerated(): bool return (bool) $filesystem->exists(app_path(static::getPolicyPath() . DIRECTORY_SEPARATOR . 'RolePolicy.php')); } - public static function isTeamFeatureEnabled(): bool + public static function isTenancyEnabled(): bool { return (bool) config()->get('permission.teams', false); }