45 lines
1.5 KiB
PHP
45 lines
1.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Database\Seeders;
|
|
|
|
use Illuminate\Database\Seeder;
|
|
use Infra\Database\Models\ArcadiaBrand;
|
|
use Infra\Database\Models\Brand;
|
|
use Ramsey\Uuid\Uuid;
|
|
|
|
final class BrandSeeder extends Seeder
|
|
{
|
|
/**
|
|
* Seed the application's database.
|
|
*/
|
|
public function run(): void
|
|
{
|
|
/** @var list<array{code: int, libelle: string, uwil_public_id: string}> $brands */
|
|
$brands = [
|
|
['code' => 1, 'libelle' => 'Le Gaulois', 'uwil_public_id' => 'LGL01'],
|
|
['code' => 2, 'libelle' => 'Maître CoQ', 'uwil_public_id' => 'MCQ02'],
|
|
['code' => 3, 'libelle' => 'Loué', 'uwil_public_id' => 'LOU03'],
|
|
['code' => 4, 'libelle' => 'Marie', 'uwil_public_id' => 'MAR04'],
|
|
['code' => 5, 'libelle' => "Tradition d'Asie", 'uwil_public_id' => 'TDA05'],
|
|
['code' => 6, 'libelle' => 'Réghalal', 'uwil_public_id' => 'REG06'],
|
|
];
|
|
|
|
foreach ($brands as $brandData) {
|
|
ArcadiaBrand::query()->updateOrCreate(
|
|
['code' => $brandData['code']],
|
|
['libelle' => $brandData['libelle']],
|
|
);
|
|
|
|
Brand::query()->firstOrCreate(
|
|
['arcadia_id' => $brandData['code']],
|
|
[
|
|
'id' => Uuid::uuid7()->toString(),
|
|
'name' => $brandData['libelle'],
|
|
'uwil_public_id' => $brandData['uwil_public_id'],
|
|
],
|
|
);
|
|
}
|
|
}
|
|
}
|