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.
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.