mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-19 22:14:45 +02:00
Installer: Shows errors on submit & move runMigrations
(#722)
* catch Halt exception to make sure error notifications are displayed * run migrations on submit to make sure the correct data is used
This commit is contained in:
parent
cd448cd9a7
commit
e0c6137b92
@ -23,8 +23,6 @@ use Filament\Notifications\Notification;
|
||||
use Filament\Pages\SimplePage;
|
||||
use Filament\Support\Enums\MaxWidth;
|
||||
use Filament\Support\Exceptions\Halt;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Routing\Redirector;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Illuminate\Support\Facades\Blade;
|
||||
use Illuminate\Support\HtmlString;
|
||||
@ -91,20 +89,26 @@ class PanelInstaller extends SimplePage implements HasForms
|
||||
return 'data';
|
||||
}
|
||||
|
||||
public function submit(UserCreationService $userCreationService): Redirector|RedirectResponse
|
||||
public function submit(UserCreationService $userCreationService): void
|
||||
{
|
||||
// Disable installer
|
||||
$this->writeToEnvironment(['APP_INSTALLED' => 'true']);
|
||||
try {
|
||||
// Disable installer
|
||||
$this->writeToEnvironment(['APP_INSTALLED' => 'true']);
|
||||
|
||||
// Create admin user & login
|
||||
$user = $this->createAdminUser($userCreationService);
|
||||
auth()->guard()->login($user, true);
|
||||
// Run migrations
|
||||
$this->runMigrations();
|
||||
|
||||
// Write session data at the very end to avoid "page expired" errors
|
||||
$this->writeToEnv('env_session');
|
||||
// Create admin user & login
|
||||
$user = $this->createAdminUser($userCreationService);
|
||||
auth()->guard()->login($user, true);
|
||||
|
||||
// Redirect to admin panel
|
||||
return redirect(Dashboard::getUrl());
|
||||
// Write session data at the very end to avoid "page expired" errors
|
||||
$this->writeToEnv('env_session');
|
||||
|
||||
// Redirect to admin panel
|
||||
$this->redirect(Dashboard::getUrl());
|
||||
} catch (Halt) {
|
||||
}
|
||||
}
|
||||
|
||||
public function writeToEnv(string $key): void
|
||||
@ -129,13 +133,12 @@ class PanelInstaller extends SimplePage implements HasForms
|
||||
Artisan::call('config:clear');
|
||||
}
|
||||
|
||||
public function runMigrations(string $driver): void
|
||||
public function runMigrations(): void
|
||||
{
|
||||
try {
|
||||
Artisan::call('migrate', [
|
||||
'--force' => true,
|
||||
'--seed' => true,
|
||||
'--database' => $driver,
|
||||
]);
|
||||
} catch (Exception $exception) {
|
||||
report($exception);
|
||||
|
@ -97,8 +97,6 @@ class DatabaseStep
|
||||
}
|
||||
|
||||
$installer->writeToEnv('env_database');
|
||||
|
||||
$installer->runMigrations($driver);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -57,8 +57,6 @@ class QueueStep
|
||||
->hidden(fn () => file_exists('/.dockerenv'))
|
||||
->columnSpanFull(),
|
||||
])
|
||||
->afterValidation(function () use ($installer) {
|
||||
$installer->writeToEnv('env_queue');
|
||||
});
|
||||
->afterValidation(fn () => $installer->writeToEnv('env_queue'));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user