xxxxxxxxxx
use Illuminate\Support\Facades\Schema;
Schema::disableForeignKeyConstraints();
// Get all table names from the database
$tables = DB::connection()->getDoctrineSchemaManager()->listTableNames();
foreach ($tables as $table) {
Schema::dropIfExists($table);
}
Schema::enableForeignKeyConstraints();
xxxxxxxxxx
//Get all the table names
$all_table_names = Schema::getConnection()->getDoctrineSchemaManager()->listTableNames();
foreach ($all_table_names as $name) {
//if you don't want to truncate migrations in Database
if ($name == 'migrations') {
continue;
}
DB::table($name)->truncate();
}
xxxxxxxxxx
foreach(\DB::select('SHOW TABLES') as $table) {
$all_table_names = get_object_vars($table);
\Schema::drop($all_table_names[key($all_table_names)]);
}