Add dev console command to reset database

This commit is contained in:
Christopher C. Wells 2021-04-22 10:25:54 -07:00
parent a378936b72
commit adc63d975c
1 changed files with 17 additions and 4 deletions

View File

@ -1,6 +1,6 @@
<?php
use Illuminate\Foundation\Inspiring;
use Illuminate\Foundation\Console\ClosureCommand;
use Illuminate\Support\Facades\Artisan;
/*
@ -14,6 +14,19 @@ use Illuminate\Support\Facades\Artisan;
|
*/
Artisan::command('inspire', function () {
$this->comment(Inspiring::quote());
})->purpose('Display an inspiring quote');
if (!App::isProduction()) {
/**
* Wipe, migrate, and seed the database.
*/
Artisan::command('dev:reset', function () {
/** @phpstan-ignore-next-line */
assert($this instanceof ClosureCommand);
Artisan::call('db:wipe');
$this->info(Artisan::output());
Artisan::call('migrate');
$this->info(Artisan::output());
Artisan::call('db:seed');
$this->info(Artisan::output());
$this->info('Database reset complete!');
})->purpose('Wipe, migrate, and seed the database.');
}