Laravel WhereBetween Query Example

Share Me
  •  
  •  
  •  
  • 1
  •  
  •  
  •  
  •  
  •  
  •  
  •  
    1
    Share
Laravel WhereBetween Query Example

Today now in this example,I will share with you how to use where between query in laravel application.we can simple use the where between query in our laravel application.

For example,we will get to user table age but need to user age get 21 to 30 in table then we can use to where between query in your controller.

We can also get the records from where between two date and also age. So here i give you the both of example are bellow. Just you need to follow 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);
}

Read Also : Laravel 8 Eloquent Global Scope Tutorial Example

I hope it will help you. Also you can follow us on Facebook

About Shahriar Sagor

My name is Shahriar sagor. I'm a developer. I live in Bangladesh and I love to write tutorials and tips that will help to other Developer's. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.

View all posts by Shahriar Sagor →