Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
[laravel] Truncate tables with foreign key
<?php
\DB::statement('SET FOREIGN_KEY_CHECKS=0');
App\Product::truncate();
App\ProductCategory::truncate();
App\ProductBrand::truncate();
App\Attribute::truncate();
App\Review::truncate();
\DB::statement('SET FOREIGN_KEY_CHECKS=1');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment