Here is my validation code in the controller
$eldate = Carbon::now()->addDay(4)->format('Y-m-d');
$validatedData = $this->validate($request, [
'ldate' => 'required|date|unique:leaves,ldate,NULL,employee,employee,'.auth()->id(),
'ldate2' => 'nullable|date|after_or_equal:ldate',
'type' => 'required'
]);
In this validation code I have to add one more condition for date1
If type =2
then ldate
should be greater than $eldate
3
Answers
use custom validation rules to solve the issue
For custom validation rules
Using Closures
Using Rule Objects
If you’re using Laravel Form Request, then simply add
I can show how to use Custom Class
documentation: https://laravel.com/docs/10.x/validation#custom-validation-rules
controller function code
And the Validation Class
i have tested it for you.