ldc-com-app-bo/database/factories/ContactFactory.php
2025-05-28 17:25:44 +02:00

41 lines
1.3 KiB
PHP

<?php
namespace Database\Factories;
use App\Models\Contact;
use Illuminate\Database\Eloquent\Factories\Factory;
class ContactFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Contact::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition(): array
{
return [
'email' => $this->faker->unique()->email(),
'lastname' => $this->faker->boolean() ? $this->faker->unique()->lastName() : null,
'firstname' => $this->faker->boolean() ? $this->faker->unique()->firstName() : null,
'phone' => $this->faker->boolean() ? $this->faker->unique()->phoneNumber() : null,
'notes' => $this->faker->boolean() ? $this->faker->text() : null,
'visits' => \collect(range(0, $this->faker->numberBetween(1, 5)))->mapWithKeys(function () {
return [
[
'title' => 'Visite du ' . $this->faker->dateTime()->format('D/M/Y H:i'),
'note' => $this->faker->text(),
]
];
}),
'data' => null,
];
}
}