Update DatabaseSeeder to include additional seeders and comment out FavoritesSeeder
- Added ProductCategoryRelationshipsSeeder, ProductBarcodesSeeder, SectionsSeeder, ProductPropertiesSeeder, and ProductPropertyValuesSeeder to DatabaseSeeder. - Commented out FavoritesSeeder and SectionsSeeder for future adjustments.
This commit is contained in:
37
database/seeders/new/SectionsSeeder.php
Normal file
37
database/seeders/new/SectionsSeeder.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders\New;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class SectionsSeeder extends Seeder
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
DB::transaction(function () {
|
||||
$datas = json_decode(File::get('database/data/sections.json'));
|
||||
$table = 'collections';
|
||||
|
||||
DB::table($table)->truncate();
|
||||
|
||||
foreach ($datas as $data) {
|
||||
DB::table($table)->insert([
|
||||
'id' => $data->id,
|
||||
'name' => str_replace('"tm"', '"tk"', $data->title),
|
||||
'slug' => Str::slug($data->title).'_'.$data->id,
|
||||
'is_visible' => ! $data->is_blocked,
|
||||
'sort_order' => $data->priority,
|
||||
'created_at' => $data->created_at,
|
||||
'updated_at' => $data->updated_at,
|
||||
]);
|
||||
}
|
||||
|
||||
DB::statement("
|
||||
SELECT setval('{$table}_id_seq', (SELECT MAX(id) from {$table}))
|
||||
");
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user