How to query between two dates using Laravel and Eloquent?

I’m trying to create a report page that shows reports from a specific date to a specific date. Here’s my current code:

$now = date('Y-m-d');
$reservations = Reservation::where('reservation_from', $now)->get();

What this does in plain SQL is select * from table where reservation_from = $now.

I have this query here but I don’t know how to convert it to eloquent query.

SELECT * FROM table WHERE reservation_from BETWEEN '$from' AND '$to

How can I convert the code above to eloquent query? Thank you in advance.

11 Answers
11

Leave a Comment