Laravel Eloquent whereBetween() Query Tutorial

Laravel eloquent whereBetween query; Through this tutorial, i am going to show you how to use whereBetween() query in laravel apps.

Laravel Eloquent whereBetween() Query Example

Let’s see the below given examples to use of whereBetween query with dates or ids in laravel apps:

  • Example 1: Laravel whereBetween query With Ids
  • Example 2: Laravel whereBetween Date Query

Example 1: Laravel whereBetween query With Ids

Let’s see the first example of laravel whereBetween query; as follows:

$users = User::whereBetween('id', [1, 50])->get();

Example 2: Laravel whereBetween Date Query

Let’s see the second example of laravel whereBetween date query; as follows:

$users = User::whereBetween('created_at', [start_date, end_date])->get();

Note that:- The whereBetween method verifies that a column’s value is between two values.

Be First to Comment

Leave a Reply

Your email address will not be published.