laravel eloquent where date between code example

Example 1: laravel between dates

$from = date('2018-01-01');
$to = date('2018-05-02');

Reservation::whereBetween('reservation_from', [$from, $to])->get();

Example 2: laravel date between

$from = date('2018-01-01');
$to = date('2018-05-02');

Reservation::whereBetween('reservation_from', [$from, $to])->get();

Example 3: find the next 7 date data in laravel eloquent

$startDate = Carbon::today();
$endDate = Carbon::today()->addDays(7);
$invoices = Invoice::whereBetween('due_date', [$startDate, $endDate])->get();
// Replace "due_date" with your actual column name
// Check your model names, they should be singular and not plural.

dd($invoices);

Tags:

Php Example