I want to validate a date that should be after todays date like tomorrow or 1 day/month/year. bu i cant get it. So far i try this
$date=Carbon::now()->today()->calendar();
$this->validate($request, [
'submission_date'=>'required|after:$date'
]);
Laravel provides after:date
and after_or_equal:date
See docs
'submission_date' => 'required|date|after:tomorrow'
// or
'submission_date' => 'required|date|after_or_equal:tomorrow'
// or
'submission_date' => 'date|after:"2019-09-30 10:48:11"',
Carbon have built-in method isFuture
to validate a future date:
$request->submission_date->isFuture()
You are on the right track. Just change some things.
$date=Carbon::now()->today();
$this->validate($request, [
'submission_date'=>"required|after:$date"
]);
look the change " " instead of ' '
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.