- Added ProductCategoryRelationshipsSeeder, ProductBarcodesSeeder, SectionsSeeder, ProductPropertiesSeeder, and ProductPropertyValuesSeeder to DatabaseSeeder. - Commented out FavoritesSeeder and SectionsSeeder for future adjustments.
33 lines
874 B
PHP
33 lines
874 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 ProductPropertyValuesSeeder extends Seeder
|
|
{
|
|
public function run()
|
|
{
|
|
DB::transaction(function () {
|
|
$table = 'attribute_value_product_attribute';
|
|
|
|
DB::table($table)->truncate();
|
|
|
|
$items = Items::fromFile(
|
|
database_path('data/item_property_values.json'),
|
|
['decoder' => new ExtJsonDecoder(true)]
|
|
);
|
|
|
|
foreach ($items as $data) {
|
|
DB::table($table)->insert([
|
|
'product_id' => $data['item_id'],
|
|
'attribute_value_id' => $data['property_value_id'],
|
|
]);
|
|
}
|
|
});
|
|
}
|
|
} |