Files
postshop-backend/database/seeders/new/PropertiesTableSeeder.php
Mekan1206 c48ad83548 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.
2026-02-09 03:29:21 +05:00

35 lines
931 B
PHP

<?php
namespace Database\Seeders\New;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\File;
class PropertiesTableSeeder extends Seeder
{
public function run()
{
$datas = json_decode(File::get('database/data/properties.json'));
$table = 'attributes';
DB::table($table)->truncate();
foreach ($datas as $data) {
DB::table($table)->insertOrIgnore([
'id' => $data->id,
'slug' => $data->code,
'name' => str_replace('"tm"', '"tk"', $data->name),
'description' => $data->description,
'type' => 'text',
'created_at' => $data->created_at,
'updated_at' => $data->updated_at,
]);
}
DB::statement("
SELECT setval('{$table}_id_seq', (SELECT MAX(id) from {$table}))
");
}
}