- Simplified `tmpostChannel` and `tmpostDefaultInventory` functions by removing caching logic. - Changed return type of `namesWithTaxes` method in `CategoryRepository` to `mixed`. - Enabled `ProductsTableSeeder` and added user association logic for product relations. - Updated `BrandsSeeder` to include the product ID in the slug. - Added `old_customer_id` to `options` in `SellersTableSeeder` for user tracking.
36 lines
986 B
PHP
36 lines
986 B
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 BrandsSeeder extends Seeder
|
|
{
|
|
public function run()
|
|
{
|
|
$datas = json_decode(File::get('database/data/brands.json'));
|
|
$table = 'brands';
|
|
|
|
DB::table($table)->truncate();
|
|
|
|
foreach ($datas as $data) {
|
|
DB::table($table)->insertOrIgnore([
|
|
'id' => $data->id,
|
|
'slug' => Str::slug(json_decode($data->name)->en ?? $data->code). '_' . $data->id,
|
|
'name' => $data->name,
|
|
'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}))
|
|
");
|
|
}
|
|
}
|