Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TRUNCATE...CASCADE in Laravel 5

This should be straightforward but I can't find it in the documentation or elsewhere. How can I TRUNCATE...CASCADE a table with foreign keys in Laravel 5.1 using the Eloquent ORM? Using just User::truncate(); doesn't pass through the CASCADE argument.

like image 748
Matthew Daly Avatar asked Sep 17 '15 13:09

Matthew Daly


1 Answers

Looks like the only way to do this is by running the statement directly:

DB::statement('TRUNCATE users CASCADE');
like image 131
Matthew Daly Avatar answered Sep 18 '22 17:09

Matthew Daly