Not sure I understand your question, but let me try.
You can use $this->input('transfered_at') to get the value of current transfered_at value to check if the sold_at is after transfered_at.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have this beautiful date validation code below that works like a charm. Now the problem is the sold_at date must before before the transferred_at date.
So my question is how would I do additional validation using before based on something something (transferred_at) that is there already?
And as a bonus, how can I update the fancy feedback messages if .before has already been used in that context? Something like before.2?
public function rules()
{
$before = Carbon::now(); // the dates cannot be in the future
$after = Carbon::now()->subDays(90); // a transfer cannot be older than 90 days
// insert new rule here where the sold_at date must be before the transferred_at date
return [
'transferred_at' => 'required|date_format:"Y-m-d"|after:' . $after . '|before:' . $before,
'sold_at' => 'required|date_format:"Y-m-d"|before:' . $before,
'photo_path' => 'max:5000000', // 5 MB
];
}
public function messages()
{
return [
'transferred_at.after' => 'The date of transfer must not be more 90 days ago',
'transferred_at.before' => 'The transfer date cannot be in the future',
'sold_at.before' => 'The date of sale cannot be in the future',
'photo_path.max' => 'The property photo cannot be larger than 5 Megabytes',
];
}
simply do this:
'transferred_at' => 'after:sold_at'
Please or to participate in this conversation.