- Added ProductCategoryRelationshipsSeeder, ProductBarcodesSeeder, SectionsSeeder, ProductPropertiesSeeder, and ProductPropertyValuesSeeder to DatabaseSeeder. - Commented out FavoritesSeeder and SectionsSeeder for future adjustments.
33 lines
838 B
PHP
33 lines
838 B
PHP
<?php
|
|
|
|
namespace Database\Seeders\New;
|
|
|
|
use Illuminate\Database\Seeder;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\File;
|
|
use JsonMachine\Items;
|
|
use JsonMachine\JsonDecoder\ExtJsonDecoder;
|
|
|
|
class ProductPropertiesSeeder extends Seeder
|
|
{
|
|
public function run()
|
|
{
|
|
DB::transaction(function () {
|
|
$table = 'product_attributes';
|
|
|
|
DB::table($table)->truncate();
|
|
|
|
$items = Items::fromFile(
|
|
database_path('data/item_properties.json'),
|
|
['decoder' => new ExtJsonDecoder(true)]
|
|
);
|
|
|
|
foreach ($items as $data) {
|
|
DB::table($table)->insert([
|
|
'product_id' => $data['item_id'],
|
|
'attribute_id' => $data['property_id'],
|
|
]);
|
|
}
|
|
});
|
|
}
|
|
} |