faker->dateTimeThisYear); $days = $this->faker->numberBetween(0, 20); return [ "user_id" => User::factory(), "creator_id" => fn(array $attributes): int => $attributes["user_id"], "year_period_id" => YearPeriod::factory(), "name" => fn(array $attributes): string => $this->generateName($attributes), "type" => $this->faker->randomElement(VacationType::cases()), "state" => $this->faker->randomElement(VacationRequestStatesRetriever::all()), "from" => $from, "to" => $from->addDays($days), "comment" => $this->faker->boolean ? $this->faker->paragraph() : null, ]; } protected function generateName(array $attributes): string { $year = YearPeriod::find($attributes["year_period_id"])->year; $number = static::$number++; return "{$number}/{$year}"; } }