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:
Mekan1206
2026-02-09 03:29:21 +05:00
parent b4a05e3f8c
commit c48ad83548
8 changed files with 183 additions and 4 deletions

View File

@@ -0,0 +1,31 @@
<?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 ProductBarcodesSeeder extends Seeder
{
public function run()
{
DB::transaction(function () {
$table = 'products';
$items = Items::fromFile(
database_path('data/item_barcodes.json'),
['decoder' => new ExtJsonDecoder(true)]
);
foreach ($items as $data) {
// item_id is product id, I need to find product and update price_amount to $data['value'] and cost_amount to $data['cost_value']
DB::table($table)->where('id', $data['item_id'])->update([
'barcode' => $data['barcode'],
]);
}
});
}
}