From c5006fe66da981f82b378d02584de0b12e82ebde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ng=C3=B4=20Qu=E1=BB=91c=20=C4=90=E1=BA=A1t?= Date: Sun, 17 Sep 2023 15:15:57 +0700 Subject: [PATCH 1/4] Introduce new fresh look for Artisan command --- src/Commands/Concerns/CanGeneratePolicy.php | 4 +- src/Commands/Concerns/CanManipulateFiles.php | 8 +- src/Commands/Concerns/CanValidateInput.php | 32 ------- src/Commands/MakeShieldDoctorCommand.php | 2 +- src/Commands/MakeShieldGenerateCommand.php | 91 +++++++++----------- src/Commands/MakeShieldInstallCommand.php | 73 ++++++++-------- src/Commands/MakeShieldPublishCommand.php | 24 +++--- src/Commands/MakeShieldSeederCommand.php | 19 ++-- src/Commands/MakeShieldSuperAdminCommand.php | 57 ++++++++---- src/Commands/MakeShieldUpgradeCommand.php | 12 +-- 10 files changed, 151 insertions(+), 171 deletions(-) delete mode 100644 src/Commands/Concerns/CanValidateInput.php diff --git a/src/Commands/Concerns/CanGeneratePolicy.php b/src/Commands/Concerns/CanGeneratePolicy.php index 3228fc10..a57d089d 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; }, collect())->toArray(); @@ -62,7 +62,7 @@ protected function generatePolicyStubVariables(array $entity): array ? 'App\Policies' : Str::of($namespace)->replace('Models', 'Policies'); /** @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 0c69c53d..59dc5e00 100644 --- a/src/Commands/Concerns/CanManipulateFiles.php +++ b/src/Commands/Concerns/CanManipulateFiles.php @@ -11,7 +11,7 @@ protected function checkForCollision(array $paths): bool { foreach ($paths as $path) { if ($this->fileExists($path)) { - $this->error("$path already exists, aborting."); + $this->components->error("$path already exists, aborting."); return true; } @@ -24,7 +24,7 @@ protected function copyStubToApp(string $stub, string $targetPath, array $replac { $filesystem = new Filesystem(); - if (! $this->fileExists($stubPath = base_path("stubs/filament/{$stub}.stub"))) { + if (!$this->fileExists($stubPath = base_path("stubs/filament/{$stub}.stub"))) { $stubPath = __DIR__ . "/../../../stubs/{$stub}.stub"; } @@ -34,7 +34,7 @@ protected function copyStubToApp(string $stub, string $targetPath, array $replac $stub = $stub->replace("{{ {$key} }}", is_array($replacement) ? json_encode($replacement) : $replacement); } - $stub = (string) $stub; + $stub = (string)$stub; $this->writeFile($targetPath, $stub); } @@ -51,7 +51,7 @@ protected function writeFile(string $path, string $contents): void $filesystem = new Filesystem(); $filesystem->ensureDirectoryExists( - (string) Str::of($path) + (string)Str::of($path) ->beforeLast(DIRECTORY_SEPARATOR), ); diff --git a/src/Commands/Concerns/CanValidateInput.php b/src/Commands/Concerns/CanValidateInput.php deleted file mode 100644 index c55c7780..00000000 --- a/src/Commands/Concerns/CanValidateInput.php +++ /dev/null @@ -1,32 +0,0 @@ -validateInput(fn () => $this->ask($question), $field, ['required']); - } - - protected function validateInput(Closure $callback, string $field, array $rules): string - { - $input = $callback(); - - $validator = Validator::make( - [$field => $input], - [$field => $rules], - ); - - if ($validator->fails()) { - $this->error($validator->errors()->first()); - - $input = $this->validateInput($callback, $field, $rules); - } - - return $input; - } -} diff --git a/src/Commands/MakeShieldDoctorCommand.php b/src/Commands/MakeShieldDoctorCommand.php index ccbb53f9..e83ac4ef 100644 --- a/src/Commands/MakeShieldDoctorCommand.php +++ b/src/Commands/MakeShieldDoctorCommand.php @@ -36,7 +36,7 @@ public function handle(): int return self::SUCCESS; } - protected static function authProviderConfigured() + protected static function authProviderConfigured(): string { if (class_exists(Utils::getAuthProviderFQCN())) { return Utils::isAuthProviderConfigured() diff --git a/src/Commands/MakeShieldGenerateCommand.php b/src/Commands/MakeShieldGenerateCommand.php index 781bc102..7700a66b 100644 --- a/src/Commands/MakeShieldGenerateCommand.php +++ b/src/Commands/MakeShieldGenerateCommand.php @@ -6,6 +6,7 @@ use BezhanSalleh\FilamentShield\Support\Utils; use Illuminate\Console\Command; use Illuminate\Support\Collection; +use Illuminate\Support\Facades\Cache; use Illuminate\Support\Str; use Symfony\Component\Console\Attribute\AsCommand; @@ -17,38 +18,32 @@ class MakeShieldGenerateCommand extends Command /** * The resources to generate permissions or policies for, or should be exclude. - * - * @var array */ - protected $resources = []; + protected array $resources = []; /** * The pages to generate permissions for, or should be excluded. - * - * @var array */ - protected $pages = []; + protected array $pages = []; /** * The widgets to generate permissions for, or should be excluded. - * - * @var array */ - protected $widgets = []; + protected array $widgets = []; - protected $generatorOption; + protected string $generatorOption; - protected $excludeResources = false; + protected bool $excludeResources = false; - protected $excludePages = false; + protected bool $excludePages = false; - protected $excludeWidgets = false; + protected bool $excludeWidgets = false; - protected $onlyResources = false; + protected bool $onlyResources = false; - protected $onlyPages = false; + protected bool $onlyPages = false; - protected $onlyWidgets = false; + protected bool $onlyWidgets = false; /** * The console command signature. @@ -76,15 +71,15 @@ class MakeShieldGenerateCommand extends Command */ public $description = 'Generate Permissions and/or Policies for Filament entities.'; - public function handle(): int + public function handle(): void { $this->determinGeneratorOptionAndEntities(); if ($this->option('exclude') && blank($this->option('resource')) && blank($this->option('page')) && blank($this->option('widget'))) { - $this->comment('No entites provided for the generators ...'); - $this->comment('... generation SKIPPED'); + $this->components->error('No entites provided for the generators ...'); + $this->components->alert('Generation skipped'); - return self::INVALID; + exit(self::INVALID); } if (filled($this->option('resource')) || $this->option('all')) { @@ -102,15 +97,15 @@ public function handle(): int $this->widgetInfo($widgets->toArray()); } - $this->comment('Permission & Policies are generated according to your config or passed options.'); - $this->info('Enjoy!'); + $this->components->info('Permission & Policies are generated according to your config or passed options.'); + $this->components->info('Enjoy!'); - if (cache()->has('shield_general_exclude')) { + if (Cache::has('shield_general_exclude')) { Utils::enableGeneralExclude(); - cache()->forget('shield_general_exclude'); + Cache::forget('shield_general_exclude'); } - return self::SUCCESS; + exit(self::SUCCESS); } protected function determinGeneratorOptionAndEntities(): void @@ -118,13 +113,13 @@ protected function determinGeneratorOptionAndEntities(): void $this->generatorOption = $this->option('option') ?? Utils::getGeneratorOption(); if ($this->option('ignore-config-exclude') && Utils::isGeneralExcludeEnabled()) { - cache()->add('shield_general_exclude', true, 3600); + Cache::add('shield_general_exclude', true, 3600); Utils::disableGeneralExclude(); } - $this->resources = (array) explode(',', $this->option('resource')); - $this->pages = (array) explode(',', $this->option('page')); - $this->widgets = (array) explode(',', $this->option('widget')); + $this->resources = explode(',', $this->option('resource')); + $this->pages = explode(',', $this->option('page')); + $this->widgets = explode(',', $this->option('widget')); $this->excludeResources = $this->option('exclude') && filled($this->option('resource')); $this->excludePages = $this->option('exclude') && filled($this->option('page')); @@ -218,41 +213,37 @@ protected function generateForPages(array $pages): Collection { return collect($pages) ->values() - ->each(function ($page) { - FilamentShield::generateForPage($page); - }); + ->each(fn (string $page) => FilamentShield::generateForPage($page)); } protected function generateForWidgets(array $widgets): Collection { return collect($widgets) ->values() - ->each(function ($widget) { - FilamentShield::generateForWidget($widget); - }); + ->each(fn (string $widget) => FilamentShield::generateForWidget($widget)); } protected function resourceInfo(array $resources): void { if ($this->option('minimal')) { - $this->info('Successfully generated Permissions & Policies.'); + $this->components->info('Successfully generated Permissions & Policies.'); } else { - $this->info('Successfully generated Permissions & Policies for:'); + $this->components->info('Successfully generated Permissions & Policies for:'); $this->table( ['#', 'Resource', 'Policy', 'Permissions'], collect($resources)->map(function ($resource, $key) { 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, $key) use ($resource) { - return $permission . '_' . $resource['resource']; + )->map(function ($permission) use ($resource) { + return $permission.'_'.$resource['resource']; })->toArray() - ) . ($this->generatorOption !== 'policies' ? ' ✅' : ' ❌'), + ).($this->generatorOption !== 'policies' ? ' ✅' : ' ❌'), ]; }) ); @@ -262,15 +253,15 @@ protected function resourceInfo(array $resources): void protected function pageInfo(array $pages): void { if ($this->option('minimal')) { - $this->info('Successfully generated Page Permissions.'); + $this->components->info('Successfully generated Page Permissions.'); } else { - $this->info('Successfully generated Page Permissions for:'); + $this->components->info('Successfully generated Page Permissions for:'); $this->table( ['#', 'Page', 'Permission'], collect($pages)->map(function ($page, $key) { return [ '#' => $key + 1, - 'Page' => Str::replace(config('filament-shield.permission_prefixes.page') . '_', '', $page), + 'Page' => Str::replace(config('filament-shield.permission_prefixes.page').'_', '', $page), 'Permission' => $page, ]; }) @@ -281,15 +272,15 @@ protected function pageInfo(array $pages): void protected function widgetInfo(array $widgets): void { if ($this->option('minimal')) { - $this->info('Successfully generated Widget Permissions.'); + $this->components->info('Successfully generated Widget Permissions.'); } else { - $this->info('Successfully generated Widget Permissions for:'); + $this->components->info('Successfully generated Widget Permissions for:'); $this->table( ['#', 'Widget', 'Permission'], collect($widgets)->map(function ($widget, $key) { return [ '#' => $key + 1, - 'Widget' => Str::replace(config('filament-shield.permission_prefixes.widget') . '_', '', $widget), + 'Widget' => Str::replace(config('filament-shield.permission_prefixes.widget').'_', '', $widget), 'Permission' => $widget, ]; }) @@ -300,9 +291,9 @@ protected function widgetInfo(array $widgets): void protected static function getPolicyStub(string $model): string { if (Str::is(Str::of(Utils::getAuthProviderFQCN())->afterLast('\\'), $model)) { - return (string) 'UserPolicy'; + return 'UserPolicy'; } - return (string) 'DefaultPolicy'; + return 'DefaultPolicy'; } } diff --git a/src/Commands/MakeShieldInstallCommand.php b/src/Commands/MakeShieldInstallCommand.php index 751bce15..df38e03b 100644 --- a/src/Commands/MakeShieldInstallCommand.php +++ b/src/Commands/MakeShieldInstallCommand.php @@ -10,6 +10,8 @@ use Illuminate\Support\Facades\Schema; use Throwable; +use function Laravel\Prompts\confirm; + class MakeShieldInstallCommand extends Command { public $signature = 'shield:install @@ -20,45 +22,45 @@ class MakeShieldInstallCommand extends Command public $description = 'Setup Core Package requirements and Install Shield'; - public function handle(): int + public function handle(): void { - if (! Utils::isAuthProviderConfigured()) { - $this->error('Please make sure your Auth Provider model (App\\Models\\User) uses either `HasRoles` or `HasFilamentShield` trait'); + if (!Utils::isAuthProviderConfigured()) { + $this->components->error('Please make sure your Auth Provider model (\App\\Models\\User) uses either `HasRoles` or `HasFilamentShield` trait'); - return self::INVALID; + exit(self::INVALID); } if ($this->option('minimal')) { $confirmed = true; } else { - $this->alert('Following operations will be performed:'); - $this->info('- Publishes core package config'); - $this->info('- Publishes core package migration'); - $this->warn(' - On fresh applications database will be migrated'); - $this->warn(' - You can also force this behavior by supplying the --fresh option'); + $this->components->alert('Following operations will be performed:'); + $this->components->info('- Publishes core package config'); + $this->components->info('- Publishes core package migration'); + $this->components->warn('- On fresh applications database will be migrated'); + $this->components->warn('- You can also force this behavior by supplying the --fresh option'); - $confirmed = $this->confirm('Do you wish to continue?', true); + $confirmed = confirm('Do you wish to continue?'); } - if ($this->CheckIfAlreadyInstalled() && ! $this->option('fresh')) { - $this->comment('Seems you have already installed the Core package(`spatie/laravel-permission`)!'); - $this->comment('You should run `shield:install --fresh` instead to refresh the Core package tables and setup shield.'); + if ($this->CheckIfAlreadyInstalled() && !$this->option('fresh')) { + $this->components->info('Seems you have already installed the Core package(`spatie/laravel-permission`)!'); + $this->components->info('You should run `shield:install --fresh` instead to refresh the Core package tables and setup shield.'); - if ($this->confirm('Run `shield:install --fresh` instead?', false)) { + if (confirm('Run `shield:install --fresh` instead?', false)) { $this->install(true); } - return self::INVALID; + exit(self::INVALID); } if ($confirmed) { $this->install($this->option('fresh')); } else { - $this->comment('`shield:install` command was cancelled.'); + $this->components->info('`shield:install` command was cancelled.'); } - if (! $this->option('minimal')) { - if ($this->confirm('Would you like to show some love by starring the repo?', true)) { + if (!$this->option('minimal')) { + if (confirm('Would you like to show some love by starring the repo?')) { if (PHP_OS_FAMILY === 'Darwin') { exec('open https://github.com/bezhanSalleh/filament-shield'); } @@ -69,25 +71,20 @@ public function handle(): int exec('start https://github.com/bezhanSalleh/filament-shield'); } - $this->line('Thank you!'); + $this->components->info('Thank you!'); } } - return self::SUCCESS; + exit(self::SUCCESS); } protected function CheckIfAlreadyInstalled(): bool { $count = $this->getTables() - ->filter(function ($table) { - return Schema::hasTable($table); - }) + ->filter(fn (string $table) => Schema::hasTable($table)) ->count(); - if ($count !== 0) { - return true; - } - return false; + return $count !== 0; } protected function getTables(): Collection @@ -95,13 +92,13 @@ protected function getTables(): Collection return collect(['role_has_permissions', 'model_has_roles', 'model_has_permissions', 'roles', 'permissions']); } - protected function install(bool $fresh = false) + protected function install(bool $fresh = false): void { $this->{$this->option('minimal') ? 'callSilent' : 'call'}('vendor:publish', [ '--provider' => 'Spatie\Permission\PermissionServiceProvider', ]); - $this->info('Core Package config published.'); + $this->components->info('Core Package config published.'); $this->{$this->option('minimal') ? 'callSilent' : 'call'}('vendor:publish', [ '--tag' => 'filament-shield-config', @@ -114,28 +111,26 @@ protected function install(bool $fresh = false) $this->getTables()->each(fn ($table) => DB::statement('DROP TABLE IF EXISTS ' . $table)); Schema::enableForeignKeyConstraints(); } catch (Throwable $e) { - $this->info($e); + $this->components->info($e); } - $this->info('Freshening up shield migrations.'); + $this->components->info('Freshening up shield migrations.'); } else { - $this->info('running shield migrations.'); + $this->components->info('running shield migrations.'); } $this->{$this->option('minimal') ? 'callSilent' : 'call'}('migrate', [ '--force' => true, ]); - if (! $this->option('only')) { - $this->newLine(); - $this->info('Generating permissions ...'); + if (!$this->option('only')) { + $this->components->info('Generating permissions ...'); $this->call('shield:generate', [ '--all' => true, '--minimal' => $this->option('minimal'), ]); - $this->newLine(); - $this->info('Creating a filament user with Super Admin Role...'); + $this->components->info('Creating a filament user with Super Admin Role...'); $this->call('shield:super-admin'); } else { $this->call('shield:generate', [ @@ -144,8 +139,8 @@ protected function install(bool $fresh = false) ]); } - $this->info(Artisan::output()); + $this->components->info(Artisan::output()); - $this->info('Filament Shield🛡 is now active ✅'); + $this->components->info('Filament Shield🛡 is now active ✅'); } } diff --git a/src/Commands/MakeShieldPublishCommand.php b/src/Commands/MakeShieldPublishCommand.php index c33b91fd..86040c91 100644 --- a/src/Commands/MakeShieldPublishCommand.php +++ b/src/Commands/MakeShieldPublishCommand.php @@ -6,28 +6,30 @@ use Illuminate\Filesystem\Filesystem; use Illuminate\Support\Str; +use function Laravel\Prompts\confirm; + class MakeShieldPublishCommand extends Command { use Concerns\CanManipulateFiles; public $signature = 'shield:publish'; - public $description = 'Publish filament shield\'s Resource.'; + public $description = "Publish filament shield's Resource."; - public function handle(): int + public function handle(Filesystem $filesystem): void { - $baseResourcePath = app_path((string) Str::of('Filament\\Resources\\Shield')->replace('\\', '/')); - $roleResourcePath = app_path((string) Str::of('Filament\\Resources\\Shield\\RoleResource.php')->replace('\\', '/')); + $baseResourcePath = app_path((string)Str::of('Filament\\Resources\\Shield')->replace('\\', '/')); + $roleResourcePath = app_path((string)Str::of('Filament\\Resources\\Shield\\RoleResource.php')->replace('\\', '/')); if ($this->checkForCollision([$roleResourcePath])) { - $confirmed = $this->confirm('Shield Resource already exists. Overwrite?', true); - if (! $confirmed) { - return self::INVALID; + $confirmed = confirm('Shield Resource already exists. Overwrite?'); + if (!$confirmed) { + exit(self::INVALID); } } - (new Filesystem())->ensureDirectoryExists($baseResourcePath); - (new Filesystem())->copyDirectory(__DIR__ . '/../Resources', $baseResourcePath); + $filesystem->ensureDirectoryExists($baseResourcePath); + $filesystem->copyDirectory(__DIR__ . '/../Resources', $baseResourcePath); $currentNamespace = 'BezhanSalleh\\FilamentShield\\Resources'; $newNamespace = 'App\\Filament\\Resources\\Shield'; @@ -38,8 +40,8 @@ public function handle(): int $this->replaceInFile($baseResourcePath . '/RoleResource/Pages/ViewRole.php', $currentNamespace, $newNamespace); $this->replaceInFile($baseResourcePath . '/RoleResource/Pages/ListRoles.php', $currentNamespace, $newNamespace); - $this->info('Shield\'s Resource have been published successfully!'); + $this->components->info("Shield's Resource have been published successfully!"); - return self::SUCCESS; + exit(self::SUCCESS); } } diff --git a/src/Commands/MakeShieldSeederCommand.php b/src/Commands/MakeShieldSeederCommand.php index 56910e34..2bdf4879 100644 --- a/src/Commands/MakeShieldSeederCommand.php +++ b/src/Commands/MakeShieldSeederCommand.php @@ -28,12 +28,12 @@ class MakeShieldSeederCommand extends Command */ public $description = 'Create a seeder file from existing/configured roles and permission, that could be used within your deploy script.'; - public function handle(): int + public function handle(): void { $path = database_path('seeders/ShieldSeeder.php'); - if (! $this->option('force') && $this->checkForCollision(paths: [$path])) { - return static::INVALID; + if (!$this->option('force') && $this->checkForCollision(paths: [$path])) { + exit(self::INVALID); } if ($this->option('generate')) { @@ -43,9 +43,9 @@ public function handle(): int } if (Utils::getRoleModel()::doesntExist() && Utils::getPermissionModel()::doesntExist()) { - $this->warn(' There are no roles or permissions to create the seeder. Please first run `shield:generate --all`'); + $this->components->warn('There are no roles or permissions to create the seeder. Please first run `shield:generate --all`'); - return static::INVALID; + exit(self::INVALID); } $directPermissionNames = collect(); @@ -71,7 +71,7 @@ public function handle(): int if (Utils::getPermissionModel()::exists()) { $directPermissions = collect(Utils::getPermissionModel()::get()) - ->filter(fn ($permission) => ! in_array($permission->name, $directPermissionNames->unique()->flatten()->all())) + ->filter(fn ($permission) => !in_array($permission->name, $directPermissionNames->unique()->flatten()->all())) ->map(fn ($permission) => [ 'name' => $permission->name, 'guard_name' => $permission->guard_name, @@ -87,10 +87,9 @@ public function handle(): int ] ); - $this->info('ShieldSeeder generated successfully.'); - $this->line('Now you can use it in your deploy script. i.e:'); - $this->line(' php artisan db:seed --class=ShieldSeeder '); + $this->components->info('ShieldSeeder generated successfully.'); + $this->components->info('Now you can use it in your deploy script. i.e: php artisan db:seed --class=ShieldSeeder'); - return self::SUCCESS; + exit(self::SUCCESS); } } diff --git a/src/Commands/MakeShieldSuperAdminCommand.php b/src/Commands/MakeShieldSuperAdminCommand.php index 10296436..30f34676 100644 --- a/src/Commands/MakeShieldSuperAdminCommand.php +++ b/src/Commands/MakeShieldSuperAdminCommand.php @@ -2,17 +2,18 @@ namespace BezhanSalleh\FilamentShield\Commands; -use BezhanSalleh\FilamentShield\Commands\Concerns\CanValidateInput; use BezhanSalleh\FilamentShield\FilamentShield; use BezhanSalleh\FilamentShield\Support\Utils; use Filament\Facades\Filament; +use Illuminate\Auth\EloquentUserProvider; use Illuminate\Console\Command; +use Illuminate\Contracts\Auth\Authenticatable; use Illuminate\Support\Facades\Hash; +use function Laravel\Prompts\{text, password}; + class MakeShieldSuperAdminCommand extends Command { - use CanValidateInput; - public $signature = 'shield:super-admin {--user= : ID of user to be made super admin.} {--panel= : Panel ID to get the configuration from.} @@ -20,7 +21,7 @@ class MakeShieldSuperAdminCommand extends Command public $description = 'Creates Filament Super Admin'; - protected $superAdmin; + protected Authenticatable $superAdmin; public function handle(): int { @@ -28,10 +29,8 @@ public function handle(): int Filament::setCurrentPanel(Filament::getPanel($this->option('panel'))); } - /** @var SessionGuard $auth */ $auth = Filament::getCurrentPanel()?->auth(); - /** @var EloquentUserProvider $userProvider */ $userProvider = $auth->getProvider(); if (Utils::getRoleModel()::whereName(Utils::getSuperAdminName())->doesntExist()) { @@ -40,12 +39,12 @@ public function handle(): int if ($this->option('user')) { $this->superAdmin = $userProvider->getModel()::findOrFail($this->option('user')); - } elseif ($userProvider->getModel()::count() === 1) { + } elseif ($usersCount = $userProvider->getModel()::count() === 1) { $this->superAdmin = $userProvider->getModel()::first(); - } elseif ($userProvider->getModel()::count() > 1) { + } elseif ($usersCount > 1) { $this->table( ['ID', 'Name', 'Email', 'Roles'], - $userProvider->getModel()::with('roles')->get()->map(function ($user) { + $userProvider->getModel()::with('roles')->get()->map(function (Authenticatable $user) { return [ 'id' => $user->id, 'name' => $user->name, @@ -55,22 +54,46 @@ public function handle(): int }) ); - $superAdminId = $this->ask('Please provide the `UserID` to be set as `super_admin`'); + $superAdminId = text( + label: 'Please provide the `UserID` to be set as `super_admin`', + required: true + ); $this->superAdmin = $userProvider->getModel()::findOrFail($superAdminId); } else { - $this->superAdmin = $userProvider->getModel()::create([ - 'name' => $this->validateInput(fn () => $this->ask('Name'), 'name', ['required']), - 'email' => $this->validateInput(fn () => $this->ask('Email address'), 'email', ['required', 'email', 'unique:' . $userProvider->getModel()]), - 'password' => Hash::make($this->validateInput(fn () => $this->secret('Password'), 'password', ['required', 'min:8'])), - ]); + $this->superAdmin = $this->createSuperAdmin($userProvider); } + $this->superAdmin->assignRole(Utils::getSuperAdminName()); $loginUrl = Filament::getCurrentPanel()?->getLoginUrl(); - $this->info("Success! {$this->superAdmin->email} may now log in at {$loginUrl}."); + $this->components->info("Success! {$this->superAdmin->email} may now log in at {$loginUrl}."); - return self::SUCCESS; + exit(self::SUCCESS); + } + + protected function createSuperAdmin(EloquentUserProvider $provider): Authenticatable + { + return $provider->getModel()::create([ + 'name' => text(label: 'Name', required: true), + 'email' => text( + label: 'Email address', + required: true, + validate: fn (string $email): ?string => match (true) { + !filter_var($email, FILTER_VALIDATE_EMAIL) => 'The email address must be valid.', + $provider->getModel()::where('email', $email)->exists() => 'A user with this email address already exists', + default => null, + }, + ), + 'password' => Hash::make(password( + label: 'Password', + required: true, + validate: fn (string $value) => match (true) { + strlen($value) < 8 => 'The password must be at least 8 characters.', + default => null + } + )), + ]); } } diff --git a/src/Commands/MakeShieldUpgradeCommand.php b/src/Commands/MakeShieldUpgradeCommand.php index 9fe7e2e1..ca56ecf8 100644 --- a/src/Commands/MakeShieldUpgradeCommand.php +++ b/src/Commands/MakeShieldUpgradeCommand.php @@ -14,12 +14,12 @@ class MakeShieldUpgradeCommand extends Command public $description = 'Upgrade shield'; - public function handle(): int + public function handle(): void { try { $path = glob(database_path('migrations/*_filament_shield_settings_table.php')); - if (! blank($path) && File::exists($path[0])) { + if (!blank($path) && File::exists($path[0])) { File::delete($path); } @@ -35,11 +35,13 @@ public function handle(): int Schema::enableForeignKeyConstraints(); } catch (Throwable $e) { - $this->info($e); + $this->components->info($e); + + exit(self::FAILURE); } - $this->info('shield upgraded.'); + $this->components->info('Filament Shield upgraded.'); - return self::SUCCESS; + exit(self::SUCCESS); } } From fabe1f865788de7ed3533466af9cbbdadb78e1fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ng=C3=B4=20Qu=E1=BB=91c=20=C4=90=E1=BA=A1t?= Date: Sun, 17 Sep 2023 15:21:18 +0700 Subject: [PATCH 2/4] Update --- src/Commands/Concerns/CanGeneratePolicy.php | 7 +++--- src/Commands/MakeShieldDoctorCommand.php | 28 ++++++++++----------- src/Commands/MakeShieldGenerateCommand.php | 28 ++++++++++----------- 3 files changed, 31 insertions(+), 32 deletions(-) diff --git a/src/Commands/Concerns/CanGeneratePolicy.php b/src/Commands/Concerns/CanGeneratePolicy.php index a57d089d..2fdb3b23 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; }, collect())->toArray(); @@ -60,9 +60,10 @@ protected function generatePolicyStubVariables(array $entity): array $stubVariables['namespace'] = Str::of($path)->contains(['vendor', 'src']) ? 'App\Policies' - : Str::of($namespace)->replace('Models', 'Policies'); /** @phpstan-ignore-line */ + : Str::of($namespace)->replace('Models', 'Policies'); + /** @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/MakeShieldDoctorCommand.php b/src/Commands/MakeShieldDoctorCommand.php index e83ac4ef..d726a468 100644 --- a/src/Commands/MakeShieldDoctorCommand.php +++ b/src/Commands/MakeShieldDoctorCommand.php @@ -13,27 +13,25 @@ class MakeShieldDoctorCommand extends Command public $description = 'Show useful info about Filament Shield'; - public function handle(): int + public function handle(): void { - if (class_exists(AboutCommand::class)) { - AboutCommand::add('Filament Shield', [ - 'Auth Provider' => Utils::getAuthProviderFQCN() . '|' . static::authProviderConfigured(), - 'Resource' => Utils::isResourcePublished() ? 'PUBLISHED' : 'NOT PUBLISHED', - 'Resource Slug' => Utils::getResourceSlug(), - 'Resource Sort' => Utils::getResourceNavigationSort(), - 'Resource Badge' => Utils::isResourceNavigationBadgeEnabled() ? 'ENABLED' : 'DISABLED', - 'Resource Group' => Utils::isResourceNavigationGroupEnabled() ? 'ENABLED' : 'DISABLED', - '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'), - ]); - } + AboutCommand::add('Filament Shield', [ + 'Auth Provider' => Utils::getAuthProviderFQCN() . '|' . static::authProviderConfigured(), + 'Resource' => Utils::isResourcePublished() ? 'PUBLISHED' : 'NOT PUBLISHED', + 'Resource Slug' => Utils::getResourceSlug(), + 'Resource Sort' => Utils::getResourceNavigationSort(), + 'Resource Badge' => Utils::isResourceNavigationBadgeEnabled() ? 'ENABLED' : 'DISABLED', + 'Resource Group' => Utils::isResourceNavigationGroupEnabled() ? 'ENABLED' : 'DISABLED', + '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'), + ]); $this->call('about', [ '--only' => 'filament_shield', ]); - return self::SUCCESS; + exit(self::SUCCESS); } protected static function authProviderConfigured(): string diff --git a/src/Commands/MakeShieldGenerateCommand.php b/src/Commands/MakeShieldGenerateCommand.php index 7700a66b..a11734db 100644 --- a/src/Commands/MakeShieldGenerateCommand.php +++ b/src/Commands/MakeShieldGenerateCommand.php @@ -125,9 +125,9 @@ protected function determinGeneratorOptionAndEntities(): void $this->excludePages = $this->option('exclude') && filled($this->option('page')); $this->excludeWidgets = $this->option('exclude') && filled($this->option('widget')); - $this->onlyResources = ! $this->option('exclude') && filled($this->option('resource')); - $this->onlyPages = ! $this->option('exclude') && filled($this->option('page')); - $this->onlyWidgets = ! $this->option('exclude') && filled($this->option('widget')); + $this->onlyResources = !$this->option('exclude') && filled($this->option('resource')); + $this->onlyPages = !$this->option('exclude') && filled($this->option('page')); + $this->onlyWidgets = !$this->option('exclude') && filled($this->option('widget')); } protected function generatableResources(): ?array @@ -135,7 +135,7 @@ protected function generatableResources(): ?array return collect(FilamentShield::getResources()) ->filter(function ($resource) { if ($this->excludeResources) { - return ! in_array(Str::of($resource['fqcn'])->afterLast('\\'), $this->resources); + return !in_array(Str::of($resource['fqcn'])->afterLast('\\'), $this->resources); } if ($this->onlyResources) { @@ -152,7 +152,7 @@ protected function generatablePages(): ?array return collect(FilamentShield::getPages()) ->filter(function ($page) { if ($this->excludePages) { - return ! in_array($page, $this->pages); + return !in_array($page, $this->pages); } if ($this->onlyPages) { @@ -169,7 +169,7 @@ protected function generatableWidgets(): ?array return collect(FilamentShield::getWidgets()) ->filter(function ($widget) { if ($this->excludeWidgets) { - return ! in_array($widget, $this->widgets); + return !in_array($widget, $this->widgets); } if ($this->onlyWidgets) { @@ -189,7 +189,7 @@ protected function generateForResources(array $resources): Collection if ($this->generatorOption === 'policies_and_permissions') { $policyPath = $this->generatePolicyPath($entity); /** @phpstan-ignore-next-line */ - if (! $this->option('ignore-existing-policies') || ($this->option('ignore-existing-policies') && ! $this->fileExists($policyPath))) { + if (!$this->option('ignore-existing-policies') || ($this->option('ignore-existing-policies') && !$this->fileExists($policyPath))) { $this->copyStubToApp(static::getPolicyStub($entity['model']), $policyPath, $this->generatePolicyStubVariables($entity)); } FilamentShield::generateForResource($entity); @@ -198,7 +198,7 @@ protected function generateForResources(array $resources): Collection if ($this->generatorOption === 'policies') { $policyPath = $this->generatePolicyPath($entity); /** @phpstan-ignore-next-line */ - if (! $this->option('ignore-existing-policies') || ($this->option('ignore-existing-policies') && ! $this->fileExists($policyPath))) { + if (!$this->option('ignore-existing-policies') || ($this->option('ignore-existing-policies') && !$this->fileExists($policyPath))) { $this->copyStubToApp(static::getPolicyStub($entity['model']), $policyPath, $this->generatePolicyStubVariables($entity)); } } @@ -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' ? ' ✅' : ' ❌'), ]; }) ); @@ -261,7 +261,7 @@ protected function pageInfo(array $pages): void collect($pages)->map(function ($page, $key) { return [ '#' => $key + 1, - 'Page' => Str::replace(config('filament-shield.permission_prefixes.page').'_', '', $page), + 'Page' => Str::replace(config('filament-shield.permission_prefixes.page') . '_', '', $page), 'Permission' => $page, ]; }) @@ -280,7 +280,7 @@ protected function widgetInfo(array $widgets): void collect($widgets)->map(function ($widget, $key) { return [ '#' => $key + 1, - 'Widget' => Str::replace(config('filament-shield.permission_prefixes.widget').'_', '', $widget), + 'Widget' => Str::replace(config('filament-shield.permission_prefixes.widget') . '_', '', $widget), 'Permission' => $widget, ]; }) From 38a3dc1a3c5403706b4afae2034e7c8db0771fe9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ng=C3=B4=20Qu=E1=BB=91c=20=C4=90=E1=BA=A1t?= Date: Sun, 17 Sep 2023 15:24:22 +0700 Subject: [PATCH 3/4] Update --- src/Commands/Concerns/CanGeneratePolicy.php | 3 +-- src/Commands/Concerns/CanManipulateFiles.php | 6 +++--- src/Commands/MakeShieldGenerateCommand.php | 16 ++++++++-------- src/Commands/MakeShieldInstallCommand.php | 6 +++--- src/Commands/MakeShieldPublishCommand.php | 2 +- src/Commands/MakeShieldSeederCommand.php | 4 ++-- src/Commands/MakeShieldSuperAdminCommand.php | 1 - src/Commands/MakeShieldUpgradeCommand.php | 2 +- 8 files changed, 19 insertions(+), 21 deletions(-) diff --git a/src/Commands/Concerns/CanGeneratePolicy.php b/src/Commands/Concerns/CanGeneratePolicy.php index 2fdb3b23..3228fc10 100644 --- a/src/Commands/Concerns/CanGeneratePolicy.php +++ b/src/Commands/Concerns/CanGeneratePolicy.php @@ -60,8 +60,7 @@ protected function generatePolicyStubVariables(array $entity): array $stubVariables['namespace'] = Str::of($path)->contains(['vendor', 'src']) ? 'App\Policies' - : Str::of($namespace)->replace('Models', 'Policies'); - /** @phpstan-ignore-line */ + : Str::of($namespace)->replace('Models', 'Policies'); /** @phpstan-ignore-line */ $stubVariables['model_name'] = $entity['model']; $stubVariables['model_fqcn'] = $namespace . '\\' . $entity['model']; $stubVariables['model_variable'] = Str::of($entity['model'])->camel(); diff --git a/src/Commands/Concerns/CanManipulateFiles.php b/src/Commands/Concerns/CanManipulateFiles.php index 59dc5e00..5da03e15 100644 --- a/src/Commands/Concerns/CanManipulateFiles.php +++ b/src/Commands/Concerns/CanManipulateFiles.php @@ -24,7 +24,7 @@ protected function copyStubToApp(string $stub, string $targetPath, array $replac { $filesystem = new Filesystem(); - if (!$this->fileExists($stubPath = base_path("stubs/filament/{$stub}.stub"))) { + if (! $this->fileExists($stubPath = base_path("stubs/filament/{$stub}.stub"))) { $stubPath = __DIR__ . "/../../../stubs/{$stub}.stub"; } @@ -34,7 +34,7 @@ protected function copyStubToApp(string $stub, string $targetPath, array $replac $stub = $stub->replace("{{ {$key} }}", is_array($replacement) ? json_encode($replacement) : $replacement); } - $stub = (string)$stub; + $stub = (string) $stub; $this->writeFile($targetPath, $stub); } @@ -51,7 +51,7 @@ protected function writeFile(string $path, string $contents): void $filesystem = new Filesystem(); $filesystem->ensureDirectoryExists( - (string)Str::of($path) + (string) Str::of($path) ->beforeLast(DIRECTORY_SEPARATOR), ); diff --git a/src/Commands/MakeShieldGenerateCommand.php b/src/Commands/MakeShieldGenerateCommand.php index a11734db..4a9a780d 100644 --- a/src/Commands/MakeShieldGenerateCommand.php +++ b/src/Commands/MakeShieldGenerateCommand.php @@ -125,9 +125,9 @@ protected function determinGeneratorOptionAndEntities(): void $this->excludePages = $this->option('exclude') && filled($this->option('page')); $this->excludeWidgets = $this->option('exclude') && filled($this->option('widget')); - $this->onlyResources = !$this->option('exclude') && filled($this->option('resource')); - $this->onlyPages = !$this->option('exclude') && filled($this->option('page')); - $this->onlyWidgets = !$this->option('exclude') && filled($this->option('widget')); + $this->onlyResources = ! $this->option('exclude') && filled($this->option('resource')); + $this->onlyPages = ! $this->option('exclude') && filled($this->option('page')); + $this->onlyWidgets = ! $this->option('exclude') && filled($this->option('widget')); } protected function generatableResources(): ?array @@ -135,7 +135,7 @@ protected function generatableResources(): ?array return collect(FilamentShield::getResources()) ->filter(function ($resource) { if ($this->excludeResources) { - return !in_array(Str::of($resource['fqcn'])->afterLast('\\'), $this->resources); + return ! in_array(Str::of($resource['fqcn'])->afterLast('\\'), $this->resources); } if ($this->onlyResources) { @@ -152,7 +152,7 @@ protected function generatablePages(): ?array return collect(FilamentShield::getPages()) ->filter(function ($page) { if ($this->excludePages) { - return !in_array($page, $this->pages); + return ! in_array($page, $this->pages); } if ($this->onlyPages) { @@ -169,7 +169,7 @@ protected function generatableWidgets(): ?array return collect(FilamentShield::getWidgets()) ->filter(function ($widget) { if ($this->excludeWidgets) { - return !in_array($widget, $this->widgets); + return ! in_array($widget, $this->widgets); } if ($this->onlyWidgets) { @@ -189,7 +189,7 @@ protected function generateForResources(array $resources): Collection if ($this->generatorOption === 'policies_and_permissions') { $policyPath = $this->generatePolicyPath($entity); /** @phpstan-ignore-next-line */ - if (!$this->option('ignore-existing-policies') || ($this->option('ignore-existing-policies') && !$this->fileExists($policyPath))) { + if (! $this->option('ignore-existing-policies') || ($this->option('ignore-existing-policies') && ! $this->fileExists($policyPath))) { $this->copyStubToApp(static::getPolicyStub($entity['model']), $policyPath, $this->generatePolicyStubVariables($entity)); } FilamentShield::generateForResource($entity); @@ -198,7 +198,7 @@ protected function generateForResources(array $resources): Collection if ($this->generatorOption === 'policies') { $policyPath = $this->generatePolicyPath($entity); /** @phpstan-ignore-next-line */ - if (!$this->option('ignore-existing-policies') || ($this->option('ignore-existing-policies') && !$this->fileExists($policyPath))) { + if (! $this->option('ignore-existing-policies') || ($this->option('ignore-existing-policies') && ! $this->fileExists($policyPath))) { $this->copyStubToApp(static::getPolicyStub($entity['model']), $policyPath, $this->generatePolicyStubVariables($entity)); } } diff --git a/src/Commands/MakeShieldInstallCommand.php b/src/Commands/MakeShieldInstallCommand.php index df38e03b..22c86b27 100644 --- a/src/Commands/MakeShieldInstallCommand.php +++ b/src/Commands/MakeShieldInstallCommand.php @@ -42,7 +42,7 @@ public function handle(): void $confirmed = confirm('Do you wish to continue?'); } - if ($this->CheckIfAlreadyInstalled() && !$this->option('fresh')) { + if ($this->CheckIfAlreadyInstalled() && ! $this->option('fresh')) { $this->components->info('Seems you have already installed the Core package(`spatie/laravel-permission`)!'); $this->components->info('You should run `shield:install --fresh` instead to refresh the Core package tables and setup shield.'); @@ -59,7 +59,7 @@ public function handle(): void $this->components->info('`shield:install` command was cancelled.'); } - if (!$this->option('minimal')) { + if (! $this->option('minimal')) { if (confirm('Would you like to show some love by starring the repo?')) { if (PHP_OS_FAMILY === 'Darwin') { exec('open https://github.com/bezhanSalleh/filament-shield'); @@ -123,7 +123,7 @@ protected function install(bool $fresh = false): void '--force' => true, ]); - if (!$this->option('only')) { + if (! $this->option('only')) { $this->components->info('Generating permissions ...'); $this->call('shield:generate', [ '--all' => true, diff --git a/src/Commands/MakeShieldPublishCommand.php b/src/Commands/MakeShieldPublishCommand.php index 86040c91..ed9fb177 100644 --- a/src/Commands/MakeShieldPublishCommand.php +++ b/src/Commands/MakeShieldPublishCommand.php @@ -23,7 +23,7 @@ public function handle(Filesystem $filesystem): void if ($this->checkForCollision([$roleResourcePath])) { $confirmed = confirm('Shield Resource already exists. Overwrite?'); - if (!$confirmed) { + if (! $confirmed) { exit(self::INVALID); } } diff --git a/src/Commands/MakeShieldSeederCommand.php b/src/Commands/MakeShieldSeederCommand.php index 2bdf4879..20f01f6e 100644 --- a/src/Commands/MakeShieldSeederCommand.php +++ b/src/Commands/MakeShieldSeederCommand.php @@ -32,7 +32,7 @@ public function handle(): void { $path = database_path('seeders/ShieldSeeder.php'); - if (!$this->option('force') && $this->checkForCollision(paths: [$path])) { + if (! $this->option('force') && $this->checkForCollision(paths: [$path])) { exit(self::INVALID); } @@ -71,7 +71,7 @@ public function handle(): void if (Utils::getPermissionModel()::exists()) { $directPermissions = collect(Utils::getPermissionModel()::get()) - ->filter(fn ($permission) => !in_array($permission->name, $directPermissionNames->unique()->flatten()->all())) + ->filter(fn ($permission) => ! in_array($permission->name, $directPermissionNames->unique()->flatten()->all())) ->map(fn ($permission) => [ 'name' => $permission->name, 'guard_name' => $permission->guard_name, diff --git a/src/Commands/MakeShieldSuperAdminCommand.php b/src/Commands/MakeShieldSuperAdminCommand.php index 30f34676..6eedf92e 100644 --- a/src/Commands/MakeShieldSuperAdminCommand.php +++ b/src/Commands/MakeShieldSuperAdminCommand.php @@ -9,7 +9,6 @@ use Illuminate\Console\Command; use Illuminate\Contracts\Auth\Authenticatable; use Illuminate\Support\Facades\Hash; - use function Laravel\Prompts\{text, password}; class MakeShieldSuperAdminCommand extends Command diff --git a/src/Commands/MakeShieldUpgradeCommand.php b/src/Commands/MakeShieldUpgradeCommand.php index ca56ecf8..554e3913 100644 --- a/src/Commands/MakeShieldUpgradeCommand.php +++ b/src/Commands/MakeShieldUpgradeCommand.php @@ -19,7 +19,7 @@ public function handle(): void try { $path = glob(database_path('migrations/*_filament_shield_settings_table.php')); - if (!blank($path) && File::exists($path[0])) { + if (! blank($path) && File::exists($path[0])) { File::delete($path); } From e5c11185088c2f89137d34d92a4aaba6987d64d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ng=C3=B4=20Qu=E1=BB=91c=20=C4=90=E1=BA=A1t?= Date: Sun, 17 Sep 2023 15:26:10 +0700 Subject: [PATCH 4/4] Update --- src/Commands/MakeShieldInstallCommand.php | 1 - src/Commands/MakeShieldPublishCommand.php | 1 - 2 files changed, 2 deletions(-) diff --git a/src/Commands/MakeShieldInstallCommand.php b/src/Commands/MakeShieldInstallCommand.php index 22c86b27..0921cd98 100644 --- a/src/Commands/MakeShieldInstallCommand.php +++ b/src/Commands/MakeShieldInstallCommand.php @@ -9,7 +9,6 @@ use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Schema; use Throwable; - use function Laravel\Prompts\confirm; class MakeShieldInstallCommand extends Command diff --git a/src/Commands/MakeShieldPublishCommand.php b/src/Commands/MakeShieldPublishCommand.php index ed9fb177..bc8d3efe 100644 --- a/src/Commands/MakeShieldPublishCommand.php +++ b/src/Commands/MakeShieldPublishCommand.php @@ -5,7 +5,6 @@ use Illuminate\Console\Command; use Illuminate\Filesystem\Filesystem; use Illuminate\Support\Str; - use function Laravel\Prompts\confirm; class MakeShieldPublishCommand extends Command