*/ class TimelineFactory extends Factory { /** * Define the model's default state. * * @return array */ public function definition(): array { return [ 'user_id' => User::factory(), 'case_name' => fake()->sentence(3), 'case_reference' => fake()->boolean(70) ? fake()->unique()->regexify('[A-Z]{2}-[0-9]{4}-[0-9]{3}') : null, 'status' => TimelineStatus::Active, ]; } /** * Create an active timeline. */ public function active(): static { return $this->state(fn (array $attributes) => [ 'status' => TimelineStatus::Active, ]); } /** * Create an archived timeline. */ public function archived(): static { return $this->state(fn (array $attributes) => [ 'status' => TimelineStatus::Archived, ]); } /** * Create a timeline with a case reference. */ public function withReference(): static { return $this->state(fn (array $attributes) => [ 'case_reference' => fake()->unique()->regexify('[A-Z]{2}-[0-9]{4}-[0-9]{3}'), ]); } }