isProduction()) { $this->error('Command not allowed in production.'); return 1; } $database = Schema::getConnection()->getDatabaseName(); if ($this->option('drop')) { $this->info("Dropping database {$database}"); Schema::dropDatabaseIfExists($database); $this->info("Creating database {$database}"); Schema::createDatabase($database); } if (! $this->option('drop')) { Schema::withoutForeignKeyConstraints(function (): void { foreach ([ ...DumpContentAction::allowedTables(), ] as $table) { $this->info("Truncating table {$table}"); DB::table($table)->truncate(); } }); } DB::statement("USE `{$database}`"); $this->info('Migrating database'); $this->call('migrate'); if (! $this->option('skip-factory')) { $this->info('Adding factory data'); $this->call('db:seed', ['class' => FactoryDataSeeder::class]); } $this->info('Seeding permissions'); $this->call('db:seed', ['class' => PermissionSeeder::class]); $this->info('Seeding roles'); $this->call('db:seed', ['class' => RoleSeeder::class]); $this->info('Seeding features'); $this->call('db:seed', ['class' => FeatureSeeder::class]); $this->info('Importing models for scout'); $this->call('scout:import-all'); return 0; } protected function validator(): Validator { return ValidatorFacade::make($this->options(), []); } }