2026-04-29 08:44:03 +03:00

43 lines
1.4 KiB
PHP

<?php
namespace Database\Seeders;
use App\Models\Client;
use App\Models\Contact;
use Illuminate\Database\Seeder;
class ContactSeeder extends Seeder
{
public function run(): void
{
Client::query()->orderBy('id')->get()->each(function (Client $client, int $index): void {
Contact::updateOrCreate(
[
'client_id' => $client->id,
'email' => sprintf('contact.%d@clients.thanasoft.test', $client->id),
],
[
'first_name' => 'Contact',
'last_name' => sprintf('Client %d', $client->id),
'phone' => sprintf('+26134000%04d', $client->id),
'role' => $index % 2 === 0 ? 'Responsable funéraire' : 'Assistant administratif',
]
);
if ($index < 8) {
Contact::updateOrCreate(
[
'client_id' => $client->id,
'email' => sprintf('famille.%d@clients.thanasoft.test', $client->id),
],
[
'first_name' => 'Référent',
'last_name' => sprintf('Famille %d', $client->id),
'phone' => sprintf('+26135000%04d', $client->id),
'role' => 'Référent famille',
]
);
}
});
}
}