diff --git a/app/Console/Commands/ResetApp.php b/app/Console/Commands/ResetApp.php index e29ba8dd..f3062501 100644 --- a/app/Console/Commands/ResetApp.php +++ b/app/Console/Commands/ResetApp.php @@ -3,17 +3,20 @@ namespace Crater\Console\Commands; use Illuminate\Console\Command; +use Illuminate\Console\ConfirmableTrait; use Illuminate\Support\Facades\Artisan; use Illuminate\Filesystem\Filesystem; class ResetApp extends Command { + use ConfirmableTrait; + /** * The name and signature of the console command. * * @var string */ - protected $signature = 'reset:app'; + protected $signature = 'reset:app {--force}'; /** * The console command description. @@ -39,13 +42,28 @@ class ResetApp extends Command */ public function handle() { - if ($this->confirm('Do you wish to continue? This will delete your tables')) { - Artisan::call('migrate:reset --force'); - - \Storage::disk('local')->delete('database_created'); - - // $file = new Filesystem; - // $file->cleanDirectory('public/storage'); + if (!$this->confirmToProceed()) { + return; } + + $this->info('Running migrate:fresh'); + + Artisan::call('migrate:fresh --seed --force'); + + $this->info('Seeding database'); + + Artisan::call('db:seed', ['--class' => 'DemoSeeder', '--force' => true]); + + $path = base_path('.env'); + + if (file_exists($path)) { + file_put_contents($path, str_replace( + 'APP_DEBUG=true', + 'APP_DEBUG=false', + file_get_contents($path) + )); + } + + $this->info('App has been reset successfully'); } }