PHP Laravel Multiple Where Condition using Eloquent

Today, We want to share with you PHP Laravel Multiple Where Condition using Eloquent.In this post we will show you where condition in laravel controller, hear for Laravel collection multiple where conditions we will give you demo and example for implement.In this post, we will learn about How to use multiple OR,AND condition in Laravel queries with an example.

List of all Google Adsense, VueJS, AngularJS, PHP, Laravel Examples.

PHP Laravel Multiple Where Condition using Eloquent

There are the Following The simple About Laravel eloquent multiple WHERE with OR AND OR and LIKE Full Information With Example and source code.

As I will cover this Post with live Working example to develop How to use multiple OR,AND condition in Laravel queries, so the How to Create Multiple Where Clause Query Using Laravel Eloquent? is used for this example is following below.

laravel two where conditions

Simple Laravel Syntax

->where('YOUR_COLUMN_NAME', 'OPERATOR', 'VALUE')
->where('YOUR_COLUMN_NAME', 'OPERATOR', 'VALUE')

using an Array Multiple Value

->where([
        ['YOUR_COLUMN_NAME', 'OPERATOR', 'VALUE'],
        ['YOUR_COLUMN_NAME', 'OPERATOR', 'VALUE']
    ]);

using MySQL Query

SELECT * FROM `products` WHERE is_bundle = 1 AND is_sell = 0

Example 1:

laravel eloquent multiple where conditions

public function index()
{
    $products = Product::select('*')
                ->where('is_bundle', '=', 1)
                ->where('is_sell', '=', 0)
                ->get();
   
    dd($products);
}

Example 2:

laravel query builder multiple where conditions

public function index()
{
    $products = Product::select('*')
                ->where([
                    ['is_bundle', '=', 1],
                    ['is_sell', '=', 0]
                ])
                ->get();
    dd($products);
}

Laravel 6 – inner join with multiple conditions example using Query Builder

$product = Product::select("products.*","menus.id as itemId","categories.id as catId")
            ->join("menus","menus.product_id","=","products.id")
            ->join("categories",function($join){
                $join->on("categories.product_id","=","products.id")
                    ->on("categories.item_id","=","menus.id");
            })
            ->get();
print_r($product);

Web Programming Tutorials Example with Demo

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about laravel eloquent multiple orwhere.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.


Related FAQ

Here are some more FAQ related to this Article:

  1.   laravel 6 auth
  2.   Double Click (ng-dblclick) using Angular Example
  3.   How to Join Two Tables in Laravel 6?
  4.   CodeIgniter Autocomplete Multiple input textbox with Database
  5.   Laravel Eloquent Multiple WHERE clauses
  6.   How to get current user details in wordpress?
  7.   Codeigniter Form Validation with Google reCAPTCHA
  8.   Retrieve Data From MySQL Database using Vue.js PHP
  9.   Create Dynamic Image Fancybox Gallery with jQuery, PHP & MySQL
  10.   VueJS Filter Currency Rounding 2 decimal places Example

Leave a Reply

Your email address will not be published. Required fields are marked *