diff --git a/src/Commands/FilamentJetstreamCommand.php b/src/Commands/FilamentJetstreamCommand.php index b931773..ee3bbb2 100644 --- a/src/Commands/FilamentJetstreamCommand.php +++ b/src/Commands/FilamentJetstreamCommand.php @@ -21,7 +21,7 @@ public function handle(): int { $this->info('Filament Jetstream scaffolding...'); - if (!$this->installFilamentPackage() || !$this->installJetstreamPackage()) { + if (! $this->installFilamentPackage() || ! $this->installJetstreamPackage()) { return self::FAILURE; } @@ -57,7 +57,7 @@ public function handle(): int */ protected function installFilamentPackage(): bool { - if (!$this->hasComposerPackage('filament/filament')) { + if (! $this->hasComposerPackage('filament/filament')) { return $this->requireComposerPackages('filament/filament:^3.2'); } @@ -69,7 +69,7 @@ protected function installFilamentPackage(): bool */ protected function installJetstreamPackage(): bool { - if (!$this->hasComposerPackage('laravel/jetstream')) { + if (! $this->hasComposerPackage('laravel/jetstream')) { return $this->requireComposerPackages('laravel/jetstream:^4.2'); } @@ -187,15 +187,15 @@ protected function configurePanel() $filesystem->ensureDirectoryExists(resource_path('views/filament/pages')); collect($filesystem->files(app_path('Providers/Filament'))) - ->map(fn(\SplFileInfo $fileInfo) => str($fileInfo->getFilename()) + ->map(fn (\SplFileInfo $fileInfo) => str($fileInfo->getFilename()) ->before('.php')->prepend("App\Providers\Filament")->append('::class,')->toString()) - ->each(fn($value) => $this->replaceInFile(search: $value, replace: '', path: config_path('app.php'))); + ->each(fn ($value) => $this->replaceInFile(search: $value, replace: '', path: config_path('app.php'))); - $filesystem->copyDirectory(__DIR__.'/../../stubs/App', app_path('/')); + $filesystem->copyDirectory(__DIR__ . '/../../stubs/App', app_path('/')); - $filesystem->copyDirectory(__DIR__.'/../../stubs/resources/views/filament', resource_path('views/filament')); + $filesystem->copyDirectory(__DIR__ . '/../../stubs/resources/views/filament', resource_path('views/filament')); - copy(__DIR__.'/../../stubs/routes/web.php', base_path('routes/web.php')); + copy(__DIR__ . '/../../stubs/routes/web.php', base_path('routes/web.php')); $this->installServiceProviderAfter('AuthServiceProvider', 'Filament\AppPanelProvider'); } @@ -284,12 +284,12 @@ protected function runCommands(array $commands): void try { $process->setTty(true); } catch (\RuntimeException $e) { - $this->output->writeln(' WARN '.$e->getMessage().PHP_EOL); + $this->output->writeln(' WARN ' . $e->getMessage() . PHP_EOL); } } $process->run(function ($type, $line) { - $this->output->write(' '.$line); + $this->output->write(' ' . $line); }); } @@ -307,14 +307,14 @@ protected function hasComposerPackage(string $package): bool /** * Installs the given Composer Packages into the application. */ - protected function requireComposerPackages(array|string $packages): bool + protected function requireComposerPackages(array | string $packages): bool { $command = array_merge( ['composer', 'require'], is_array($packages) ? $packages : func_get_args() ); - return !(new Process($command, base_path(), ['COMPOSER_MEMORY_LIMIT' => '-1'])) + return ! (new Process($command, base_path(), ['COMPOSER_MEMORY_LIMIT' => '-1'])) ->setTimeout(null) ->run(function ($type, $output) { $this->output->write($output); @@ -326,15 +326,15 @@ protected function requireComposerPackages(array|string $packages): bool */ protected function installServiceProviderAfter(string $after, string $name): void { - if (!Str::contains( + if (! Str::contains( $appConfig = file_get_contents(config_path('app.php')), - 'App\\Providers\\'.$name.'::class' + 'App\\Providers\\' . $name . '::class' )) { file_put_contents( config_path('app.php'), str_replace( - 'App\\Providers\\'.$after.'::class,', - 'App\\Providers\\'.$after.'::class,'.PHP_EOL.' App\\Providers\\'.$name.'::class,', + 'App\\Providers\\' . $after . '::class,', + 'App\\Providers\\' . $after . '::class,' . PHP_EOL . ' App\\Providers\\' . $name . '::class,', $appConfig ) ); diff --git a/stubs/App/Filament/Pages/ApiTokens.php b/stubs/App/Filament/Pages/ApiTokens.php index 6583d64..9c7ca57 100644 --- a/stubs/App/Filament/Pages/ApiTokens.php +++ b/stubs/App/Filament/Pages/ApiTokens.php @@ -3,6 +3,7 @@ namespace App\Filament\Pages; use Filament\Pages\Page; + class ApiTokens extends Page { protected static ?string $navigationIcon = 'heroicon-o-key'; diff --git a/stubs/App/Filament/Pages/CreateTeam.php b/stubs/App/Filament/Pages/CreateTeam.php index e49d654..e7251ad 100644 --- a/stubs/App/Filament/Pages/CreateTeam.php +++ b/stubs/App/Filament/Pages/CreateTeam.php @@ -6,6 +6,7 @@ use Filament\Forms\Form; use Filament\Pages\Tenancy\RegisterTenant; use Illuminate\Database\Eloquent\Model; + class CreateTeam extends RegisterTenant { public static function getLabel(): string diff --git a/stubs/App/Filament/Pages/EditProfile.php b/stubs/App/Filament/Pages/EditProfile.php index 2e1dc94..3f43bd1 100644 --- a/stubs/App/Filament/Pages/EditProfile.php +++ b/stubs/App/Filament/Pages/EditProfile.php @@ -3,6 +3,7 @@ namespace App\Filament\Pages; use Filament\Pages\Page; + class EditProfile extends Page { protected static ?string $navigationIcon = 'heroicon-o-user-circle'; diff --git a/stubs/App/Filament/Pages/EditTeam.php b/stubs/App/Filament/Pages/EditTeam.php index 3024b1e..ac5b374 100644 --- a/stubs/App/Filament/Pages/EditTeam.php +++ b/stubs/App/Filament/Pages/EditTeam.php @@ -4,6 +4,7 @@ use Filament\Facades\Filament; use Filament\Pages\Tenancy\EditTenantProfile; + class EditTeam extends EditTenantProfile { protected static string $view = 'filament.pages.edit-team'; diff --git a/stubs/App/Providers/Filament/AppPanelProvider.php b/stubs/App/Providers/Filament/AppPanelProvider.php index 6d50e21..b56c8c8 100644 --- a/stubs/App/Providers/Filament/AppPanelProvider.php +++ b/stubs/App/Providers/Filament/AppPanelProvider.php @@ -51,7 +51,7 @@ public function panel(Panel $panel): Panel MenuItem::make() ->label('Profile') ->icon('heroicon-o-user-circle') - ->url(fn() => $this->shouldRegisterMenuItem() + ->url(fn () => $this->shouldRegisterMenuItem() ? url(EditProfile::getUrl()) : url($panel->getPath())), ]) @@ -87,7 +87,7 @@ public function panel(Panel $panel): Panel MenuItem::make() ->label('API Tokens') ->icon('heroicon-o-key') - ->url(fn() => $this->shouldRegisterMenuItem() + ->url(fn () => $this->shouldRegisterMenuItem() ? url(ApiTokens::getUrl()) : url($panel->getPath())), ]); @@ -102,7 +102,7 @@ public function panel(Panel $panel): Panel MenuItem::make() ->label('Team Settings') ->icon('heroicon-o-cog-6-tooth') - ->url(fn() => $this->shouldRegisterMenuItem() + ->url(fn () => $this->shouldRegisterMenuItem() ? url(EditTeam::getUrl()) : url($panel->getPath())), ]); diff --git a/stubs/routes/web.php b/stubs/routes/web.php index 0a13db9..1e9e746 100644 --- a/stubs/routes/web.php +++ b/stubs/routes/web.php @@ -15,13 +15,13 @@ | */ -Route::get('/', fn() => view('welcome')); +Route::get('/', fn () => view('welcome')); -Route::redirect('/login', "/app/login")->name('login'); +Route::redirect('/login', '/app/login')->name('login'); -Route::redirect('/register', "/app/register")->name('register'); +Route::redirect('/register', '/app/register')->name('register'); -Route::redirect('/dashboard', "/app")->name('dashboard'); +Route::redirect('/dashboard', '/app')->name('dashboard'); Route::get('/team-invitations/{invitation}', [TeamInvitationController::class, 'accept']) ->middleware(['signed', 'verified', 'auth:filament', AuthenticateSession::class])