*/ class TownFactory extends Factory { /** * Define the model's default state. * * @return array */ public function definition(): array { return [ 'town_pid' => 'TWN'.$this->faker->unique()->numerify('####'), 'town_name' => $this->faker->city(), 'state' => $this->faker->numberBetween(1, 8), 'population' => $this->faker->numberBetween(100, 500000), 'town_class' => $this->faker->numberBetween(0, 5), 'date_retired' => null, ]; } public function retired(): static { return $this->state(fn (array $attributes) => [ 'date_retired' => now()->subDays(30), ]); } public function inState(\App\Enums\AustralianState $state): static { return $this->state(fn (array $attributes) => [ 'state' => $state->value, ]); } }