I built a booking form where user can select a starting date & time for the booking, but now I'm facing some issues to validate it.
If the beginning_date
is today, the beginning_time
should not be below than the current time, but,if the beginning_date
is tomorrow than time can be anything.
I've tried to implement some rules, but it doesn't seem to work, I also had a look at laravel docs but doeesn't seem that there's anything for this problem.
What I've tried so far is :
$validated = $request->validate([
'beginning_date' => "bail|required|after_or_equal:' . date(DATE_ATOM)'",
'beginning_time' => [
'required',
Rule::when(('beginning_date' > date(DATE_ATOM)), "after_or_equal:" . Carbon::now()->format('H:i'))
],
'quantity' => 'bail|digits_between:1,9',
'duration' => 'required',
'type'=>'required'
]);
But it doesn't seem to work. Do you have any idea on how i can validate this inputs?
Thank you
0 comments:
Post a Comment
Thanks