Is there a way I could truncate all the tables in a db using eloquent or fluent in laravel 4? I do not want to specify table names, I just want to truncate all the tables. In ot
Use this:
$tables = DB::select('SHOW TABLES');
// it do truncate all tables in database
foreach($tables as $table){
if ($table == 'migrations') {
continue;
}
DB::table($table->Tables_in_portal_test)->truncate();
}
Remember you import
use Illuminate\Support\Facades\DB;
PD: Tables_in_YOUR_DATABASE_NAME