From ecd92c0b0b559c675b86c1e623bdd75c75961e19 Mon Sep 17 00:00:00 2001 From: Bubka <858858+Bubka@users.noreply.github.com> Date: Fri, 20 Mar 2020 23:15:36 +0100 Subject: [PATCH] Reset demo in a lighter way --- app/Console/Commands/ResetDemo.php | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/app/Console/Commands/ResetDemo.php b/app/Console/Commands/ResetDemo.php index bc94df49..41d4691c 100644 --- a/app/Console/Commands/ResetDemo.php +++ b/app/Console/Commands/ResetDemo.php @@ -3,6 +3,7 @@ namespace App\Console\Commands; use Illuminate\Console\Command; +use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Storage; class ResetDemo extends Command @@ -59,6 +60,12 @@ public function handle() $icons = Storage::allFiles('public/icons'); Storage::delete($icons); + $filesForDelete = array_filter(glob('public/icons/*'), function($file) { + return false === strpos($file, '.gitignore'); + }); + + Storage::delete($filesForDelete); + $this->line('Existing icons deleted'); // Regenerate icons for seeded accounts @@ -75,26 +82,19 @@ public function handle() $this->line('Icons regenerated'); // Reset the db - $this->callSilent('migrate:fresh'); + DB::table('users')->truncate(); + DB::table('oauth_access_tokens')->truncate(); + DB::table('twofaccounts')->truncate(); + DB::table('options')->truncate(); // Seed the db $this->callSilent('db:seed', [ '--class' => 'DemoSeeder' ]); - $this->line('Database reset and seeded'); + $this->line('Database cleaned and seeded'); - // Reset auth - $this->callSilent('passport:install'); - - $this->line('Passport installed'); - - // Reset auth - $this->callSilent('config:cache'); - - $this->line('Config cached'); - - $this->info('App ready for demo usage'); + $this->info('Demo app refreshed'); } else { $this->comment('Bad confirmation word, nothing appened');