Laravel WhereBetween Query Example

Laravel 6 , Laravel

Nicesnippets

185

06-01-2020


Hi Guys,

In this example,I will show you how to use where between query in laravel.you can simple use the where between query in laravel.

for example,you will get to user table age but user age get 21 to 30 in table then use to where between query in controller.

You can also get records from where between two date and age. So i give you both example are bellow you can see both example as bellow:

Example 1 :

/**

* The attributes that are mass assignable.

*

* @var array

*/

public function index()

{

$users = DB::table('users')

->whereBetween('created_at',['2019-12-25','2019-12-30'] )

->get();

dd($users);

}

Example 2 :

/**

* The attributes that are mass assignable.

*

* @var array

*/

public function index()

{

$users = DB::table('users')

->whereBetween('age',[21,30] )

->get();

dd($users);

}

It will help you...


Recommended Posts