Multiple Where Condition Example In Laravel

  Oct 2023
  ITSolutionsGuides
  Category: Laravel
Multiple Where Condition Example In Laravel

Hi Developers,

Lets see How to use Multiple Where Condition in a single query In Laravel, In some cases we need to fetch the details with multiple conditions to be satisfied, for example sometimes we need to fetch all the staff details with specific gender and also the currently active staffs , In this cases we need to use multiple where conditions in a single query to fetch the staff details. So lets see how it done.

Master the art of filtering data in Laravel with multiple 'where' conditions. Dive into practical examples, empowering you to efficiently query and retrieve precisely the data your application needs. Elevate your Laravel skills with this insightful tutorial.

Let's Start Coding

Lets fetch the users details which the users are active and not admin , by using separate where conditions in a single query.

public function index()
{
    $users = User::where('active', '=', 1)
                ->where('is_admin', '=', 0)
                ->get();
   
    dd($users);
}

Let's Start Coding

Lets fetch the users details which the users are active and not admin , but in this method we are using single where condition with two conditions.

public function index()
{
    $users = User::where([
                    ['active', '=', 1],
                    ['is_admin', '=', 0]
                ])
                ->get();
   
    dd($users);
}

We hope it helps everyone. Thanks for supporting ITSolutionsGuides and keep supporting us also follow us in social media platforms.

Subscribe for NewsLetter

Be the first to know about releases and tutorial news and solutions.

We care about your data in our privacy policy.

ITSolutionsGuides

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.

Contact US

ITSolutionsGuides, provide users with an easy-to-use form to reach out for support or inquiries.

whatsapp  gmail  instagram-new--v1  facebook-circled  twitter-circled  linkedin  github  pinterest 

Copyright © 2023 - 2024 All rights reserved | ITSolutionsGuides