From adc63d975c08f58dd2d6f037c7eaf69c8aea7ec9 Mon Sep 17 00:00:00 2001 From: "Christopher C. Wells" Date: Thu, 22 Apr 2021 10:25:54 -0700 Subject: [PATCH] Add dev console command to reset database --- routes/console.php | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/routes/console.php b/routes/console.php index e05f4c9..079ee29 100644 --- a/routes/console.php +++ b/routes/console.php @@ -1,6 +1,6 @@ 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.'); +}