In this post, we will see Laravel whereBetween query model. SQL gives numerous different sorts of techniques or queries to get separated information from the data set. Thus, in this post, we will learn Laravel orWhereBetween query model.
Here I will give you the code of the Laravel whereBetween() query model, in below code I have added Laravel whereBetween() with orWhereBetween() SQL query just as the Laravel query.
First we will see how to use BETWEEN Operator in SQL.
SQL BETWEEN Operator Example
select * from `user` where `user_id` between value1 and value2
Laravel whereBetween() Query
$students = DB::table('user')
->whereBetween('user_id', [10, 50])
->get();
Here we will see another guide to,get all records between two dates by utilizing BETWEEN Operator and whereBetween() in SQL and Laravel
select * from `user` where `created_at` between value1 and value2
class RegisterController extends Controller
{
public function index(Request $request)
{
$names = Register::whereBetween('created_at',[$request->start_date,$request->$end_date])->get();
}
}
I hope you will like the content and it will help you to learn Laravel whereBetween Query Example
If you like this content, do share.