I have a table with column starts_at
and ends_at
data type datetime. the input is a date. How can i select all record where the date (input) that is between starts_at
and ends_at
wiht laravel query builder?
Solved : Model::where('starts_at', '>=', $date)->where('ends_at', '<=', $date)->get()
If these columns were added to the $dates
property and you already converted the input date to Carbon instance:
if ($model->starts_at->lt($inputDate) && $model->ends_at->gt($inputDate))