This commit is contained in:
2026-02-03 15:31:29 +05:00
commit 326c677e8d
2800 changed files with 1489388 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
<?php
namespace Database\Seeders;
use Exception;
use File;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class ProductHasRelationsTable extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
$datas = json_decode(File::get('database/data/product_has_relations.json'));
$table = 'product_has_relations';
try {
foreach ($datas as $data) {
DB::table($table)->insert([
'product_id' => $data->product_id,
'productable_type' => $this->getProductableType($data->productable_type),
'productable_id' => $data->productable_id,
]);
}
} catch (Exception $e) {
info(['Ignore error', $e->getMessage()]);
}
}
/**
* Get productable type
*/
public function getProductableType(string $name): string
{
return match ($name) {
'collection' => 'collection',
'App\\Models\\Shop\\Channel' => 'channel',
'category' => 'category',
};
}
}