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', ] ); } }); } }