68 lines
1.8 KiB
PHP
68 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Enums\PetTypeEnum;
|
|
use App\Enums\PetGenderEnum;
|
|
use App\Models\User;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
/**
|
|
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Pet>
|
|
*/
|
|
class PetFactory extends Factory
|
|
{
|
|
|
|
public function definition(): array
|
|
{
|
|
return [
|
|
'name' => fake()->firstName(),
|
|
'type' => fake()->randomElement(PetTypeEnum::cases()),
|
|
'gender' => fake()->randomElement(PetGenderEnum::cases()),
|
|
'breed' => fake()->word(),
|
|
'weight' => fake()->numberBetween(1, 50),
|
|
'sterilized' => fake()->boolean(),
|
|
'birthday' => fake()->dateTimeBetween('-15 years', '-1 year'),
|
|
'owner_id' => User::factory(),
|
|
];
|
|
}
|
|
|
|
|
|
public function dog(): static
|
|
{
|
|
return $this->state(fn (array $attributes) => [
|
|
'type' => PetTypeEnum::Dog,
|
|
'breed' => fake()->randomElement(['ژرمن شپرد', 'گلدن رتریور', 'لابادور', 'بولداگ', 'پودل']),
|
|
]);
|
|
}
|
|
|
|
public function cat(): static
|
|
{
|
|
return $this->state(fn (array $attributes) => [
|
|
'type' => PetTypeEnum::Cat,
|
|
'breed' => fake()->randomElement(['پرشین', 'سیامی', 'مین کون', 'رگدال', 'بنگال']),
|
|
]);
|
|
}
|
|
|
|
public function male(): static
|
|
{
|
|
return $this->state(fn (array $attributes) => [
|
|
'gender' => PetGenderEnum::Male,
|
|
]);
|
|
}
|
|
|
|
public function female(): static
|
|
{
|
|
return $this->state(fn (array $attributes) => [
|
|
'gender' => PetGenderEnum::Female,
|
|
]);
|
|
}
|
|
|
|
public function sterilized(): static
|
|
{
|
|
return $this->state(fn (array $attributes) => [
|
|
'sterilized' => true,
|
|
]);
|
|
}
|
|
}
|