Hi Developers,
Lets see how to use multiple where condition in a Laravel Query Builder. In some conditions we need to check two or more conditions before fetching the data from the database, So lets see how its done. Multiple Where condition in a Laravel Query Builder
Example 1 : In First example we are using two where condition
public function index()
{
$users = User::select('*')
->where('active', '=', 1)
->where('is_admin', '=', 1)
->get();
dd($users);
}
Example 2 : In this example we are using single where condition but using two conditions in a single where condition
public function index()
{
$users = User::select('*')
->where([
['active', '=', 1],
['is_admin', '=', 1]
])
->get();
dd($users);
}
We hope it helps everyone. Thanks for supporting ITSolutionsGuides and keep supporting us also follow us in social media platforms.
Be the first to know about releases and tutorial news and solutions.
We care about your data in our privacy policy.
ITSolutionsGuides was started mainly to provide good and quality web solutions for all the developers. We provide tutorials to support all the developers and also we try to provide solutions to the errors we face while coding.
Copyright © 2023 - 2024 All rights reserved | ITSolutionsGuides