ldc-legaulois/database/factories/CustomerFactory.php
2026-09-28 10:51:17 +02:00

47 lines
1.2 KiB
PHP

<?php
namespace Database\Factories;
use App\Models\Customer;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Customer>
*/
class CustomerFactory extends Factory
{
protected $model = Customer::class;
#[\Override]
protected function withFaker()
{
return class_exists(\Faker\Generator::class) ? parent::withFaker() : null;
}
public function definition(): array
{
return $this->faker !== null
? $this->definitionWithFaker()
: $this->definitionStatic();
}
/** @return array<string, mixed> */
private function definitionWithFaker(): array
{
return [
'email' => fake()->unique()->email(),
'hashcode' => fake()->unique()->uuid(),
'username' => fake()->unique()->userName(),
];
}
/** @return array<string, mixed> */
private function definitionStatic(): array
{
return [
'email' => 'client.test@exemple.org',
'hashcode' => '00000000-0000-0000-0000-000000000000',
'username' => 'client_demo',
];
}
}