*/ class CityFactory extends Factory { /** * Define the model's default state. * * @return array */ public function definition(): array { return [ 'name' => fake()->randomElement(City::supportedCities()), 'label' => function ($attributes) { return match ($attributes['name']) { City::SANAA => 'صنعاء', City::ADEN => 'عدن', default => $attributes['name'], }; }, ]; } public function sanaa() { return $this->state([ 'name' => City::SANAA, ]); } public function aden() { return $this->state([ 'name' => City::ADEN, ]); } }