*/ class TodoFactory extends Factory { /** * Define the model's default state. * * @return array */ public function definition(): array { return [ 'user_id' => User::factory(), 'folder_id' => Folder::factory(), 'description' => fake()->sentence(6), 'due_date' => today()->addDays(5), 'completed_at' => null, ]; } /** * Indicate that the todo has no due date. */ public function noDueDate(): static { return $this->state(fn (array $attributes) => [ 'due_date' => null, ]); } /** * Indicate that the todo has notes. */ public function withNotes(): static { return $this->state(fn (array $attributes) => [ 'notes' => fake()->paragraph(), ]); } /** * Indicate that the todo has been completed. */ public function completed(): static { return $this->state(fn (array $attributes) => [ 'completed_at' => now(), ]); } /** * Indicate that the todo is overdue. */ public function overdue(): static { return $this->state(fn (array $attributes) => [ 'due_date' => today()->subDays(3), 'completed_at' => null, ]); } /** * Indicate that the todo is due today and still open. */ public function dueToday(): static { return $this->state(fn (array $attributes) => [ 'due_date' => today(), 'completed_at' => null, ]); } }