Files
InvoiceShelf/app/Platform/Operations/Console/ResetApp.php
T
Darko Gjorgjijoski 7db2a8d094 feat(operations): fresh platform-operations implementation
Full rewrite of the installer (incl. the finish step), self-update pipeline,
settings store, cron webhook, dashboard/bootstrap surface, environment
manager, wizard login, config endpoint and shared helpers. Byte-compatible
public interfaces and observable behavior, including documented legacy
quirks; verified by the pilot behavioral suite and the full test suite.
2026-08-20 18:30:12 +02:00

63 lines
1.8 KiB
PHP

<?php
namespace App\Platform\Operations\Console;
use Illuminate\Console\Command;
use Illuminate\Console\ConfirmableTrait;
use Illuminate\Support\Facades\Artisan;
use function Laravel\Prompts\confirm;
/**
* Development helper that throws the instance away and rebuilds it with demo
* data. Everything in the database goes; there is no undo.
*
* The app is taken down for the duration so nobody can talk to a half-migrated
* schema, and brought back up as the final step.
*/
class ResetApp extends Command
{
use ConfirmableTrait;
protected $signature = 'reset:app {--force}';
protected $description = 'Clean database and public/storage folder';
public function handle(): void
{
if (! $this->cleared()) {
$this->components->error('Reset cancelled');
return;
}
$this->step('Activating maintenance mode...', 'down');
$this->step('Running migrate:fresh', 'migrate:fresh --seed --force');
$this->step('Seeding database', 'db:seed', ['--class' => 'DemoSeeder', '--force' => true]);
$this->step('Clearing cache...', 'optimize:clear');
$this->step('Deactivating maintenance mode...', 'up');
$this->info('App reset completed successfully!');
}
/**
* Whether the operator has agreed to lose the database — either up front
* with --force, or by answering the prompt.
*/
private function cleared(): bool
{
return (bool) $this->option('force')
|| confirm('Are you sure you want to reset the application?');
}
/**
* Announce a stage, then hand it to Artisan.
*/
private function step(string $announcement, string $command, array $arguments = []): void
{
$this->info($announcement);
Artisan::call($command, $arguments);
}
}