I'm using a Nova action to change a date. To validate the date change, I need to make sure the new date is after the old date. For some reason I'm having a really hard time accessing the old date (which is not a field, just a value attached to the user model). This is what I have:
public function fields()
{
// Get old date. This works when the action loads.
$oldShipDate = Carbon::parse($this->user->ship_date)
return [
Date::make('New Ship Date', 'new_ship_date')
// Using withMeta so that calendar pops up with old ship date selected - this works
->withMeta(['value' => $oldShipDate])
->rules('required','after:' . $oldShipDate),
}),
// Other fields
];
}
I see in Nova 4.0 they've added a min() option that would fix all of this, but I'm on Nova 3.0. I've also tried a custom validation function and a custom rule, but I still can't access $this->user when the form is submitted. Is it possible to access ship_date on validation somehow? Last resort is to check the new date against the old date in the action logic, but that feels hacky.