41 lines
1.0 KiB
PHP
41 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Enums\Gender;
|
|
use App\Models\Customer;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
class CustomerFactory extends Factory
|
|
{
|
|
protected $model = Customer::class;
|
|
|
|
public function definition(): array
|
|
{
|
|
return [
|
|
'name' => $this->faker->name(),
|
|
'phone_number' => $this->faker->randomElement([
|
|
$this->faker->numerify('0812 #### ###'),
|
|
$this->faker->numerify('0812 #### ####'),
|
|
$this->faker->numerify('0812 #### #####'),
|
|
]),
|
|
'gender' => $this->faker->randomElement(Gender::cases()),
|
|
];
|
|
}
|
|
|
|
public function withAddress(): Factory
|
|
{
|
|
return $this->state(fn () => ['address' => $this->faker->address()]);
|
|
}
|
|
|
|
public function male(): Factory
|
|
{
|
|
return $this->state(fn () => ['gender' => Gender::MALE]);
|
|
}
|
|
|
|
public function female(): Factory
|
|
{
|
|
return $this->state(fn () => ['gender' => Gender::FEMALE]);
|
|
}
|
|
}
|