diff --git a/src/Commands/Concerns/CanGeneratePolicy.php b/src/Commands/Concerns/CanGeneratePolicy.php index 87a6fc07..6df9d25d 100644 --- a/src/Commands/Concerns/CanGeneratePolicy.php +++ b/src/Commands/Concerns/CanGeneratePolicy.php @@ -45,7 +45,7 @@ protected function generatePolicyStubVariables(array $entity): array { $stubVariables = collect(Utils::getResourcePermissionPrefixes($entity['fqcn'])) ->reduce(function ($gates, $permission) use ($entity) { - $gates[Str::studly($permission)] = $permission . '_' . $entity['resource']; + $gates[Str::studly($permission)] = $permission.'_'.$entity['resource']; return $gates; }, []); @@ -59,10 +59,10 @@ protected function generatePolicyStubVariables(array $entity): array $path = $reflectionClass->getFileName(); $stubVariables['namespace'] = Str::of($path)->contains(['vendor', 'src']) - ? 'App\\' . Utils::getPolicyNamespace() + ? 'App\\'.Utils::getPolicyNamespace() : Str::of($namespace)->replace('Models', Utils::getPolicyNamespace()); /** @phpstan-ignore-line */ $stubVariables['model_name'] = $entity['model']; - $stubVariables['model_fqcn'] = $namespace . '\\' . $entity['model']; + $stubVariables['model_fqcn'] = $namespace.'\\'.$entity['model']; $stubVariables['model_variable'] = Str::of($entity['model'])->camel(); $stubVariables['modelPolicy'] = "{$entity['model']}Policy"; diff --git a/src/Commands/Concerns/CanManipulateFiles.php b/src/Commands/Concerns/CanManipulateFiles.php index ef01b54b..9b5c7629 100644 --- a/src/Commands/Concerns/CanManipulateFiles.php +++ b/src/Commands/Concerns/CanManipulateFiles.php @@ -25,7 +25,7 @@ protected function copyStubToApp(string $stub, string $targetPath, array $replac $filesystem = new Filesystem; if (! $this->fileExists($stubPath = base_path("stubs/filament/{$stub}.stub"))) { - $stubPath = __DIR__ . "/../../../stubs/{$stub}.stub"; + $stubPath = __DIR__."/../../../stubs/{$stub}.stub"; } $stub = Str::of($filesystem->get($stubPath)); diff --git a/src/Commands/MakeShieldDoctorCommand.php b/src/Commands/MakeShieldDoctorCommand.php index d7850022..8aaae463 100644 --- a/src/Commands/MakeShieldDoctorCommand.php +++ b/src/Commands/MakeShieldDoctorCommand.php @@ -16,7 +16,7 @@ class MakeShieldDoctorCommand extends Command public function handle(): int { AboutCommand::add('Filament Shield', [ - 'Auth Provider' => Utils::getAuthProviderFQCN() . '|' . static::authProviderConfigured(), + 'Auth Provider' => Utils::getAuthProviderFQCN().'|'.static::authProviderConfigured(), 'Resource' => Utils::isResourcePublished() ? 'PUBLISHED' : 'NOT PUBLISHED', 'Resource Slug' => Utils::getResourceSlug(), 'Resource Sort' => Utils::getResourceNavigationSort(), diff --git a/src/Commands/MakeShieldGenerateCommand.php b/src/Commands/MakeShieldGenerateCommand.php index 1893b714..de613eaf 100644 --- a/src/Commands/MakeShieldGenerateCommand.php +++ b/src/Commands/MakeShieldGenerateCommand.php @@ -235,15 +235,15 @@ protected function resourceInfo(array $resources): void return [ '#' => $key + 1, 'Resource' => $resource['model'], - 'Policy' => "{$resource['model']}Policy.php" . ($this->generatorOption !== 'permissions' ? ' ✅' : ' ❌'), + 'Policy' => "{$resource['model']}Policy.php".($this->generatorOption !== 'permissions' ? ' ✅' : ' ❌'), 'Permissions' => implode( - ',' . PHP_EOL, + ','.PHP_EOL, collect( Utils::getResourcePermissionPrefixes($resource['fqcn']) )->map(function ($permission) use ($resource) { - return $permission . '_' . $resource['resource']; + return $permission.'_'.$resource['resource']; })->toArray() - ) . ($this->generatorOption !== 'policies' ? ' ✅' : ' ❌'), + ).($this->generatorOption !== 'policies' ? ' ✅' : ' ❌'), ]; }) ); diff --git a/src/Commands/MakeShieldInstallCommand.php b/src/Commands/MakeShieldInstallCommand.php index 8fa93abb..720dd66e 100644 --- a/src/Commands/MakeShieldInstallCommand.php +++ b/src/Commands/MakeShieldInstallCommand.php @@ -108,7 +108,7 @@ protected function install(bool $fresh = false): void try { Schema::disableForeignKeyConstraints(); DB::table('migrations')->where('migration', 'like', '%_create_permission_tables')->delete(); - $this->getTables()->each(fn ($table) => DB::statement('DROP TABLE IF EXISTS ' . $table)); + $this->getTables()->each(fn ($table) => DB::statement('DROP TABLE IF EXISTS '.$table)); Schema::enableForeignKeyConstraints(); } catch (Throwable $e) { $this->components->info($e); diff --git a/src/Commands/MakeShieldPublishCommand.php b/src/Commands/MakeShieldPublishCommand.php index 44b924f9..c9cfae16 100644 --- a/src/Commands/MakeShieldPublishCommand.php +++ b/src/Commands/MakeShieldPublishCommand.php @@ -29,16 +29,16 @@ public function handle(Filesystem $filesystem): int } $filesystem->ensureDirectoryExists($baseResourcePath); - $filesystem->copyDirectory(__DIR__ . '/../Resources', $baseResourcePath); + $filesystem->copyDirectory(__DIR__.'/../Resources', $baseResourcePath); $currentNamespace = 'BezhanSalleh\\FilamentShield\\Resources'; $newNamespace = 'App\\Filament\\Resources\\Shield'; $this->replaceInFile($roleResourcePath, $currentNamespace, $newNamespace); - $this->replaceInFile($baseResourcePath . '/RoleResource/Pages/CreateRole.php', $currentNamespace, $newNamespace); - $this->replaceInFile($baseResourcePath . '/RoleResource/Pages/EditRole.php', $currentNamespace, $newNamespace); - $this->replaceInFile($baseResourcePath . '/RoleResource/Pages/ViewRole.php', $currentNamespace, $newNamespace); - $this->replaceInFile($baseResourcePath . '/RoleResource/Pages/ListRoles.php', $currentNamespace, $newNamespace); + $this->replaceInFile($baseResourcePath.'/RoleResource/Pages/CreateRole.php', $currentNamespace, $newNamespace); + $this->replaceInFile($baseResourcePath.'/RoleResource/Pages/EditRole.php', $currentNamespace, $newNamespace); + $this->replaceInFile($baseResourcePath.'/RoleResource/Pages/ViewRole.php', $currentNamespace, $newNamespace); + $this->replaceInFile($baseResourcePath.'/RoleResource/Pages/ListRoles.php', $currentNamespace, $newNamespace); $this->components->info("Shield's Resource have been published successfully!"); diff --git a/src/Concerns/CanCustomizeColumns.php b/src/Concerns/CanCustomizeColumns.php index 713d6cfe..75a94e0e 100644 --- a/src/Concerns/CanCustomizeColumns.php +++ b/src/Concerns/CanCustomizeColumns.php @@ -6,109 +6,109 @@ trait CanCustomizeColumns { - protected int | string | array $checkboxListColumnSpan = 'full'; + protected int|string|array $checkboxListColumnSpan = 'full'; - protected int | string | array $checkboxListColumns = [ + protected int|string|array $checkboxListColumns = [ 'sm' => 2, 'lg' => 4, ]; - protected int | string | array $gridColumns = 1; + protected int|string|array $gridColumns = 1; - protected int | string | array $resourceCheckboxListColumnSpan = 'full'; + protected int|string|array $resourceCheckboxListColumnSpan = 'full'; - protected int | string | array $resourceCheckboxListColumns = [ + protected int|string|array $resourceCheckboxListColumns = [ 'sm' => 2, 'lg' => 4, ]; - protected int | string | array $sectionColumnSpan = 'full'; + protected int|string|array $sectionColumnSpan = 'full'; - protected int | string | array $sectionColumns = [ + protected int|string|array $sectionColumns = [ 'sm' => 2, 'lg' => 4, ]; - public function checkboxListColumns(int | string | array $columns): static + public function checkboxListColumns(int|string|array $columns): static { $this->checkboxListColumns = $columns; return $this; } - public function checkboxListColumnSpan(int | string | array $columnSpan): static + public function checkboxListColumnSpan(int|string|array $columnSpan): static { $this->checkboxListColumnSpan = $columnSpan; return $this; } - public function gridColumns(int | string | array $columns): static + public function gridColumns(int|string|array $columns): static { $this->gridColumns = $columns; return $this; } - public function resourceCheckboxListColumns(int | string | array $columns): static + public function resourceCheckboxListColumns(int|string|array $columns): static { $this->resourceCheckboxListColumns = $columns; return $this; } - public function resourceCheckboxListColumnSpan(int | string | array $columnSpan): static + public function resourceCheckboxListColumnSpan(int|string|array $columnSpan): static { $this->resourceCheckboxListColumnSpan = $columnSpan; return $this; } - public function sectionColumns(int | string | array $columns): static + public function sectionColumns(int|string|array $columns): static { $this->sectionColumns = $columns; return $this; } - public function sectionColumnSpan(int | string | array $columnSpan): static + public function sectionColumnSpan(int|string|array $columnSpan): static { $this->sectionColumnSpan = $columnSpan; return $this; } - public function getCheckboxListColumns(): int | string | array + public function getCheckboxListColumns(): int|string|array { return $this->checkboxListColumns; } - public function getCheckboxListColumnSpan(): int | string | array + public function getCheckboxListColumnSpan(): int|string|array { return $this->checkboxListColumnSpan; } - public function getGridColumns(): int | string | array + public function getGridColumns(): int|string|array { return $this->gridColumns; } - public function getResourceCheckboxListColumns(): int | string | array + public function getResourceCheckboxListColumns(): int|string|array { return $this->resourceCheckboxListColumns; } - public function getResourceCheckboxListColumnSpan(): int | string | array + public function getResourceCheckboxListColumnSpan(): int|string|array { return $this->resourceCheckboxListColumnSpan; } - public function getSectionColumns(): int | string | array + public function getSectionColumns(): int|string|array { return $this->sectionColumns; } - public function getSectionColumnSpan(): int | string | array + public function getSectionColumnSpan(): int|string|array { return $this->sectionColumnSpan; } diff --git a/src/FilamentShield.php b/src/FilamentShield.php index dce88297..37e39d62 100755 --- a/src/FilamentShield.php +++ b/src/FilamentShield.php @@ -61,7 +61,7 @@ public function generateForResource(array $entity): void collect($permissionPrefixes) ->each(function ($prefix) use ($entity, $permissions) { $permissions->push(Utils::getPermissionModel()::firstOrCreate( - ['name' => $prefix . '_' . $entity['resource']], + ['name' => $prefix.'_'.$entity['resource']], ['guard_name' => Utils::getFilamentAuthGuard()] )); }); @@ -94,7 +94,7 @@ public static function generateForWidget(string $widget): void } } - protected static function giveSuperAdminPermission(string | array | Collection $permissions): void + protected static function giveSuperAdminPermission(string|array|Collection $permissions): void { if (! Utils::isSuperAdminDefinedViaGate() && Utils::isSuperAdminEnabled()) { $superAdmin = static::createRole(); @@ -301,10 +301,10 @@ public static function getLocalizedWidgetLabel(string $widget): string return match (true) { $widgetInstance instanceof TableWidget => (string) invade($widgetInstance)->makeTable()->getHeading(), ! ($widgetInstance instanceof TableWidget) && $widgetInstance instanceof Widget && method_exists($widgetInstance, 'getHeading') => (string) invade($widgetInstance)->getHeading(), - default => str($widget) + default => __(str($widget) ->afterLast('\\') ->headline() - ->toString(), + ->toString()), }; } @@ -318,7 +318,7 @@ protected function getDefaultPermissionIdentifier(string $resource): string ->replace('_', '::'); } - protected static function getWidgetInstanceFromWidgetConfiguration(string | WidgetConfiguration $widget): string + protected static function getWidgetInstanceFromWidgetConfiguration(string|WidgetConfiguration $widget): string { return $widget instanceof WidgetConfiguration ? $widget->widget @@ -333,7 +333,7 @@ public function getAllResourcePermissions(): array Utils::getResourcePermissionPrefixes($resourceEntity['fqcn']) ) ->flatMap(function ($permission) use ($resourceEntity) { - $name = $permission . '_' . $resourceEntity['resource']; + $name = $permission.'_'.$resourceEntity['resource']; $permissionLabel = FilamentShieldPlugin::get()->hasLocalizedPermissionLabels() ? str(static::getLocalizedResourcePermissionLabel($permission)) ->prepend( diff --git a/src/Resources/RoleResource.php b/src/Resources/RoleResource.php index c73dd30d..2349a610 100644 --- a/src/Resources/RoleResource.php +++ b/src/Resources/RoleResource.php @@ -211,7 +211,7 @@ public static function getResourceEntitiesSchema(): ?array ); return Forms\Components\Section::make($sectionLabel) - ->description(fn () => new HtmlString('' . Utils::showModelPath($entity['fqcn']) . '')) + ->description(fn () => new HtmlString(''.Utils::showModelPath($entity['fqcn']).'')) ->compact() ->schema([ static::getCheckBoxListComponentForResource($entity), @@ -233,7 +233,7 @@ public static function getResourcePermissionOptions(array $entity): array { return collect(Utils::getResourcePermissionPrefixes($entity['fqcn'])) ->flatMap(function ($permission) use ($entity) { - $name = $permission . '_' . $entity['resource']; + $name = $permission.'_'.$entity['resource']; $label = static::shield()->hasLocalizedPermissionLabels() ? FilamentShield::getLocalizedResourcePermissionLabel($permission) : $name; diff --git a/src/Support/Utils.php b/src/Support/Utils.php index 8a805e94..8f6955f9 100644 --- a/src/Support/Utils.php +++ b/src/Support/Utils.php @@ -254,6 +254,6 @@ protected static function isRolePolicyGenerated(): bool { $filesystem = new Filesystem; - return (bool) $filesystem->exists(app_path(static::getPolicyPath() . DIRECTORY_SEPARATOR . 'RolePolicy.php')); + return (bool) $filesystem->exists(app_path(static::getPolicyPath().DIRECTORY_SEPARATOR.'RolePolicy.php')); } } diff --git a/tests/TestCase.php b/tests/TestCase.php index e652a01f..28f4d15d 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -14,7 +14,7 @@ protected function setUp(): void parent::setUp(); Factory::guessFactoryNamesUsing( - fn (string $modelName) => 'BezhanSalleh\\FilamentShield\\Database\\Factories\\' . class_basename($modelName) . 'Factory' + fn (string $modelName) => 'BezhanSalleh\\FilamentShield\\Database\\Factories\\'.class_basename($modelName).'Factory' ); }