public function run() { DB::table('categories')->delete(); Category::unguard(); Category::create(array('id' => 1, 'name' => 'Root 1', 'lft' => 1, 'rgt' => 10, 'depth' => 0)); Category::create(array('id' => 2, 'name' => 'Child 1', 'lft' => 2, 'rgt' => 3, 'depth' => 1, 'parent_id' => 1)); Category::create(array('id' => 3, 'name' => 'Child 2', 'lft' => 4, 'rgt' => 7, 'depth' => 1, 'parent_id' => 1)); Category::create(array('id' => 4, 'name' => 'Child 2.1', 'lft' => 5, 'rgt' => 6, 'depth' => 2, 'parent_id' => 3)); Category::create(array('id' => 5, 'name' => 'Child 3', 'lft' => 8, 'rgt' => 9, 'depth' => 1, 'parent_id' => 1)); Category::create(array('id' => 6, 'name' => 'Root 2', 'lft' => 11, 'rgt' => 12, 'depth' => 0)); // $this->nestUptoAt(Category::create(array('id' => 6, 'name' => 'Root 2' , 'lft' => 11 , 'rgt' => 12 , 'depth' => 0))); Category::reguard(); if (DB::connection()->getDriverName() === 'pgsql') { $tablePrefix = DB::connection()->getTablePrefix(); $sequenceName = $tablePrefix . 'categories_id_seq'; DB::connection()->statement('ALTER SEQUENCE ' . $sequenceName . ' RESTART WITH 7'); } }