Skip to content

Commit

Permalink
Merge pull request #7673 from Jigsaw5279/feature/check-for-panel-prov…
Browse files Browse the repository at this point in the history
…ider

Extend InstallCommand to check if PanelProvider exists if necessary
  • Loading branch information
danharrin authored Aug 12, 2023
2 parents 20f67f2 + aa49977 commit 2973ef3
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions packages/support/src/Commands/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Filament\Support\Commands;

use Filament\PanelProvider;
use Filament\Support\Commands\Concerns\CanManipulateFiles;
use Illuminate\Console\Command;
use Illuminate\Filesystem\Filesystem;
Expand All @@ -20,7 +21,9 @@ class InstallCommand extends Command
public function __invoke(): int
{
if ($this->option('panels')) {
$this->installAdminPanel();
if (! $this->installAdminPanel()) {
return static::FAILURE;
}
}

if ($this->option('scaffold')) {
Expand Down Expand Up @@ -51,12 +54,18 @@ public function __invoke(): int
return static::SUCCESS;
}

protected function installAdminPanel(): void
protected function installAdminPanel(): bool
{
$path = app_path('Providers/Filament/AdminPanelProvider.php');

if (! $this->option('force') && $this->checkForCollision([$path])) {
return;
return true;
}

if (! class_exists(PanelProvider::class)) {
$this->components->error('Please require [filament/filament] before attempting to install the Panel Builder.');

return false;
}

$this->copyStubToApp('AdminPanelProvider', $path);
Expand All @@ -71,6 +80,8 @@ protected function installAdminPanel(): void

$this->components->info('Successfully created AdminPanelProvider.php!');
$this->components->warn('We\'ve attempted to register the AdminPanelProvider in your [config/app.php] file as a service provider. If you get an error while trying to access your panel then this process has probably failed. You can manually register the service provider by adding it to the [providers] array.');

return true;
}

protected function installScaffolding(): void
Expand Down

0 comments on commit 2973ef3

Please sign in to comment.