/** * Execute the console command. * * @return mixed */ public function fire() { $database = Config::get('database')['connections']['mysql']['database']; $tables = DB::select("select * from information_schema.tables where table_schema='" . $database . "'"); DB::statement('SET foreign_key_checks = 0'); foreach ($tables as $table) { Schema::drop($table->TABLE_NAME); } DB::statement('SET foreign_key_checks = 1'); }
/** * Execute the console command. * * @return mixed */ public function handle() { try { /* * Truncante Data Dummy */ $tableNames = \Schema::getConnection()->getDoctrineSchemaManager()->listTableNames(); foreach ($tableNames as $key => $name) { if ($name == 'migrations') { continue; } \DB::statement('TRUNCATE TABLE ' . $name . ' CASCADE'); } /* * Call Artisan Command Default Data */ \Artisan::call('db:seed'); echo PHP_EOL . "Sukses" . PHP_EOL; } catch (Exception $e) { echo PHP_EOL . "Failed" . PHP_EOL; } }