Is there any way in which we could validate the date is between two particular dates. For Example; Given an input date I want it to be between 1st of July to 31st of July. The start and end dates are generated based on the current date.
I have a form request in which i am providing the validation rules. Now for validating date, I am using before and after validators. My problem is, the date I want to pass to the before and after validators are calculated from today either by subtracting or adding days to the current date. After that,I am passing the modified date to the validator.
public function rules()
{
$date_i_want = Carbon::now()->subDays(15);
return [
'date'=>'required|before:${date_i_want}'
];
}
But this doesn't seem to be working. Is there any way i could pass the variable to the before validator.