Reset demo in a lighter way

This commit is contained in:
Bubka 2020-03-20 23:15:36 +01:00
parent e2b9b5b685
commit ecd92c0b0b

View File

@ -3,6 +3,7 @@
namespace App\Console\Commands; namespace App\Console\Commands;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
class ResetDemo extends Command class ResetDemo extends Command
@ -59,6 +60,12 @@ public function handle()
$icons = Storage::allFiles('public/icons'); $icons = Storage::allFiles('public/icons');
Storage::delete($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'); $this->line('Existing icons deleted');
// Regenerate icons for seeded accounts // Regenerate icons for seeded accounts
@ -75,26 +82,19 @@ public function handle()
$this->line('Icons regenerated'); $this->line('Icons regenerated');
// Reset the db // 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 // Seed the db
$this->callSilent('db:seed', [ $this->callSilent('db:seed', [
'--class' => 'DemoSeeder' '--class' => 'DemoSeeder'
]); ]);
$this->line('Database reset and seeded'); $this->line('Database cleaned and seeded');
// Reset auth $this->info('Demo app refreshed');
$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');
} }
else { else {
$this->comment('Bad confirmation word, nothing appened'); $this->comment('Bad confirmation word, nothing appened');