Files
postshop-backend/database/seeders/new/SectionsSeeder.php
Mekan1206 b0c6a4236c Refactor seeders for improved clarity and functionality
- Reorganized imports in DatabaseSeeder for better structure.
- Enabled ProductCategoryRelationshipsSeeder and ProductBarcodesSeeder in DatabaseSeeder.
- Updated ProductPropertyValuesSeeder to enhance property value handling and added a new method for filling product property values.
- Removed unused imports from ProductBarcodesSeeder, ProductCategoryRelationshipsSeeder, and ProductPropertiesSeeder.
- Ensured consistent formatting by adding missing newlines at the end of files.
2026-02-11 00:59:13 +05:00

38 lines
1.1 KiB
PHP

<?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}))
");
});
}
}