*/ class ScheduleFactory extends Factory { public function definition(): array { return [ 'planner_id' => null, 'date' => fake()->dateTimeBetween('-5 years', 'now')->format('Y-m-d'), 'is_skipped' => false, ]; } public function planner(Planner $planner): self { return $this->state(fn (array $attributes) => [ 'planner_id' => $planner->id, ]); } public function date(string|Carbon $date): self { if ($date instanceof Carbon) { $date = $date->format('Y-m-d'); } return $this->state(fn (array $attributes) => [ 'date' => $date, ]); } public function skipped(): self { return $this->state(fn (array $attributes) => [ 'is_skipped' => true, ]); } }