["required", "min:3", "max:150"], "date" => ["required", "date", new YearPeriodExists()], ]; } public function data(): array { $date = $this->get("date"); return [ "name" => $this->get("name"), "date" => $date, "year_period_id" => YearPeriod::findByYear(Carbon::create($date)->year)->id, ]; } }