Skip to content

Instantly share code, notes, and snippets.

@ooooak
Created February 19, 2018 12:20
Show Gist options
  • Save ooooak/71fd0a710f12d9125834c01f5ee0d46c to your computer and use it in GitHub Desktop.
Save ooooak/71fd0a710f12d9125834c01f5ee0d46c to your computer and use it in GitHub Desktop.
[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