Using multiple Where clause Query in Laravel.

2024-04-27 10:35:37 Sujeet Laravel

How to Create Multiple Where Clause Query Using Laravel Eloquent?


Simply add an array of condition in where function of laravel Eloquent to create multiple where clause.

Here is an example of multiple where conditions in Laravel.

<?php
$conditions=['condtion1'=>'condition','condtion2'=>'condition','condtion3'=>'condition',......... 'condtionn'=>'condition'];

$results=YourModel::where($conditions)->get();

?>


You can also add conditions like this

$query->where([
    ['column_1', '=', 'value_1'],
    ['column_2', '<>', 'value_2'],
    [COLUMN, OPERATOR, VALUE],
    ...
])


This post is submitted by one of our members. You may submit a new post here.

Related Tricks