My guess was to use the following syntax:
MyModel::all()->delete();
But that did not work. I\'m sure it\'s super simple, but I\'ve searched
Solution who works with Lumen 5.5 with foreign keys constraints :
$categories = MusicCategory::all();
foreach($categories as $category)
{
$category->delete();
}
return response()->json(['error' => false]);
The best way for accomplishing this operation in Laravel 3
seems to be the use of the Fluent
interface to truncate the table as shown below
DB::query("TRUNCATE TABLE mytable");