laravel where multiple conditions

Solutions on MaxInterview for laravel where multiple conditions by the best coders in the world

showing results for - "laravel where multiple conditions"
Erwan
14 Mar 2019
1  public function index()
2    {
3        $search = "Har";
4  
5        $users = User::select("*")->where('status', 1)
6                  ->where(function($query) use ($search){
7                   $query->where('first_name', 'LIKE', '%'.$search.'%')
8                   ->orWhere('last_name', 'LIKE', '%'.$search.'%')
9                   ->orWhere('email', 'LIKE', '%'.$search.'%');
10                    })->get();
11  
12        dd($users);
13    }
14
15# With Join
16  public function index()
17    {
18        $search = "Har";
19  
20        $users = User::select("*")->where('status', 1)
21                  ->where(function($query) use ($search){
22                   $query->where('first_name', 'LIKE', '%'.$search.'%')
23                   ->orWhere('last_name', 'LIKE', '%'.$search.'%')
24                   ->orWhere('email', 'LIKE', '%'.$search.'%');
25                    })
26          ->join('users_roles', 'users.id', '=', 'users_roles.user_id')
27          ->where('users_roles.role_id', '=', Role::USER_PARTICIPANT)->get();
28  
29        dd($users);
30    }
Aitana
01 Jun 2017
1// ...
2$q->where(function ($query) {
3    $query->where('gender', 'Male')
4        ->where('age', '>=', 18);
5})->orWhere(function($query) {
6    $query->where('gender', 'Female')
7        ->where('age', '>=', 65);	
8})
Jenny
27 Oct 2018
1//laravel
2// here, i have used two different where condition on a single column
3$today = Carbon::today();
4$data = Users::where('type',1)
5        ->where(function($query) use ($today) {
6            return $query->whereDate('updated_at','!=', $today)
7            ->orWhere('updated_at',null);
8         })
9         ->get();
queries leading to this page
laravel search query with multiple conditionsmulti where in model in laravellaravel multiple orwhere and and not workinglaravel update multiple where clausesmultiple conditions sql statement laravellaravel select record with several conditionshow to put where condition with laravellaravel 7 orwhere with multiple conditionsmultiple where in sql query laravelmultiple where laravellaravel where multiple valuesmultiple if condition in laravel queryeloquent where with multiple conditionsmultiple and or condition in laravel blademultiple where condition using if in laravelcheck multiple where condition in laravelwhere 2 condition laravellaravel eloquent multiple where and orwherelaravel orm with multiple conditioneloquent where two or conditionlaravel query builder multiple where conditionsmultiwhere in laravel querywhere 2 conditions in laravel controllerlaravel multiple where conditionmultiple where exists laraveleloquent multiples where and orwherelaravel where clause with multiple conditions not equallaravel eloquent where two conditionsselect query based on a column in laravel multiple conditionhow to set two where condition in laravellaravel eloquent where andwherelaravel more than one where conditionlaravel model muliteloquent multiple where is nothow to have multiple conditions in eloquent laravelwhere condition on created by in laravelquery multi condition laravellaravel multiple statementsmultiple where conditions elequentorwhere multiple laravelhow to use orwhere in laravel with multiple where conditionlaravel where 2 conditionmultiple where query in laravellaravel model two wherequery for multiple where clauses laravelmultiple query in laravelmultiple where condition laravellaravel find one with multiple where conditionshow to multiple where condition in laravellaravel how to work multy where two where clause in laravelhow to select multiple where conditions in laravel sql querylaravel multiple where statementslaravel multiple or condition inside whereeloquent multiple wheremultiple and wherein laravel2 value in one column where conditions laravelmultiple condition where laravel 7multiple condition in where laravelmultiple logic in laravel 8 eloquentwhere conditionn on two column in laravel multiple where clause in select laravellaravel find multiple wheremultiple where inside where or laravellaravel model where multiple conditionslaravel where and conditionmultiple logical condition in laravel query2 value in where conditions laravel2 where clauses in laraveladd more than 1 where condition in laravel lumen eloquent where clauselaravel where statement conditionlaravel create and wheremultiple where in laravel eloquentlaravel mutliple condition in where clause2 or more with laravel relationship conditionlaravel where multiple conditions on single colmnlaravel where with multiple conditionsmultiple where condition in laraveleloquent multiple where to arraymultiple where laravel andwherehow to specify multiple values in 3ewherein 28 29 clause in laravel eloquet querylaravel where and clause with multiple conditionshow to use two where condition in laravelquery for multiple condition coumns laravelmultiple where and andwherein laraveleloquent database query to apply two where clausehow check two condition in where in laravelmulti where laravel elequenthow to write 2 where condition in laravel eloquentin operator with where condition in laravellaravel firstwhere multiple and conditionslaravel 3a eloquent multiple wheremultiple conditions laravel querylaravel where 28 29 to check multiple conditionslaravel multiple wherelaravel using multiple statement in where clauseall 28 29 3b with two condition in laravelorwhere laravel two conditionshow to give 2 conditions in where in laravellaravel when for two where clausemultiple where clause eloquent laravelmultiple tables where in laravellaravel multiple and where querylaravel where one column multiple conditionlaravel do tow where with andwhere two conditions in laravel in one whereselect with multiple conditions in laravelmultiple where on single column laravellaravel eloquent where two conditions arraywhere condition in laravel set two whare condition in laravel using modellaravel multiple where checklaravel where two conditionslaravel eloquent multiple wherelaravel check multi wherelaravel multiple or wheremultiple where condition in laravel eloquentlaravel where more than one and conditionmultiple wheres laravelwhere many parameter eloquentwherenot for multiple values laravelusing multiple where in laravelquery where with two and conditions laravellaravel where with 2 conditions truetwo condition in where mysql laravelwhere condition in eloquent laravelmultiple where eloquentlaravel wherein multiple columnseloquent query with multiple condition2 with in laravelwhere condition eloquent multiplemultiple where condition in laravel as arraylaravel querries multiple wheresmultiple where clause in laravel 8how to use multiple where condition in laravel eloquentlaravel db query with two conditionslaravel where multiplelaravel where multiple conditionsmultiple where and orwhere in laraveladd two condition in where in eloquent ormorwhere multiple where laravelmultiple orwhere condition in laravellaravel wherein two conditionslaravel where more than one optionmultiple condition in orm laravelhow to use 2 where clause in laravellaravel eloquent multiple where conditioneloquent multiple orwherelaravel query builder have multiple conditions in where calusewhere multi condition laravelquery multiple condition laravellaravel firstwhere multiple conditionslaravel multiple with use to where has query unlaravel eloquent where multiple conditionsuser where condition laravelinside where using 2 condition i laravel laravel eloquent query with conditionmultiple where condition in sql in laravelmultiple orwhere in laravellaravel hasone multiple columnslaravel query double where and where notwhere with multiple conditions and or laravelhow to use where multiple condition in laravel6multiple where condition in laravel querylaravel find where multiplesfilter by multiple conditions laravellaravel query with multiple whereeloquent where multiple or conditionslaravel where with or conditionfind with multiple conditions laravellaravel eloquent where multiple valuelaravel eloquent multiple value wherewhere condition with matching multiple elements query laravellaravel where multiple conditions or2 where condition in laravel eloquenttwo where clauses sql laravel dblaravel query on two conditionswhere mutiple condition in laravelmultiple when in laravel querywith laravel where condition ormmultiple where condition in laravel query builderhow condition for multiple row by orwhere laravellaravel multiple column where conditionhow to set query multipal where in laravel eleqountlaravel multiple orwherecheck multiple conditions in where clause laravel ormmultiple orwheres laravelmultiple with clause in laravel 5 how can use find in set multiple times in where clause in laravelhow to apply multiple where condition in sql in laravellaravel php 8 multiple where conditionmultiple where statement laravellaravel db query multiple where oreloquent orm multiple wherelaravel two where conditionseloquent database query to apply two where clause with andwhere with multiple conditions laravellaravel where multiple conditions on single column laravellaravel or where conditiontwo where but or condition in laravellaravel multi condition selectmultiple where clause eloquenttwo conditional where with and in laravel eloquentwith and where condition in laravelhow to make and in where clause laraveltwo condition in where in laravelmultiple condition in laravel wherewhere multiple conditions equivalent laravellaravel where two or plus andmultiple where in laraveldb 3a 3atable 28 24table 29 3ewhere multiple conditionslaravel query with two conditionlaravel model where clauseuse multiple where clause and not in condition in laravelwhere with two conditions laravellaravel 2 where conditions in onemultiple where conditions in laravel eloquentmulti orwhere laravelmultiple where clause in laravelmultiple query laravel eloquenttwo where condition with and in laravellaravel where has two conditionlaravel check 2 conditionsmultiple conditions in where laravellaravel multiple where clausesmultiple where eloquent laravelmultiple conditions in where close in laravelmultiple conditions in laravel wherehow to use multiple condition in laravellaravel with comment where conditionlaravel eloquent several wheremultiple where not in clause in eloquent querylaravel model multiple where and orwherelaravel select column with 2 conditionsorwhere with more conditions laraveleloquent get with complex condition multiple conditions in where clause sql laravel laravel multiple wherein columnsmulti where laravelmultiple where clause laravellmultiple where clause in laravel modellaravel first or create with two conditionsusing multiple values in a where clause laravel eloquentlaravel multi wherelaravel 2 condition in a whereto check multiple condition in where condition in laravel databasehow to add 2 variables in eloquent querylaravel eloquent orm where conditionmultiple where condition on same column in laravelquery where with two conditions laravelmultiple where clauses laravel with orlaravel use orm on where cluselaravel query with multiple orwherelaravel where clause with multiple conditionslaravel db query multiple wheredoble where en eloquentlaravel multiple querylaravel eloquent two wherelaravel multiple with use to where has query runselect two where condition query buildermultiple condition where laravelcondition where laravelmultiple with with laravel query buildermcreate two where larevelmultiple when clause laravelfind with multiple query in laravel eloquentwhere with multiple conditions in laravellaravel eloquen t query with conditionmultiple condition in where clause in laravelmultiple where clause laravel in one wherehow to write multiple conditions in where clause laraveltwo where condition in laravellaravel multiple where conditionsmultiple when condition laravellaravel multiple and or where conditionsmultiple where condition in eloquentmultiple and or where clause laravel eloquentmultiple where clause in laravel eloquentdb select with two where laravelmultiple where laravel 8laravel multiple where and orwherewhere multiple conditions sql laravellaravel where condition multiple matchmultiple where condition in where clause in laravelhow to to apply multiple where condition in laravelmulticondiaion with like in laravel with arraycheck where multiple laravelmultiple where condition in laravel 8laravel chek 2 where conditionslaravel have two where conditionsmultiple statement in where laravelmore than 2 where conditions in laravelmultiple where statements in laraveleloquent where multiple conditions with same columnmultiple where conditions laravellaravel where several conditionslaravel multiple condition on jointwo where condition in laravel querynon eaual multi column where cluse in laravelinside where using 2 condition in laravellaravel multiple with functiontwo conditions in query builder laravelmultiple query laravel eloquent with if 2 conditions in laravel query builderuswer 3a 3awith where conditon eloqvantlaravel query multiple conditionslaravel eloquent multiple orwhereeloquent get with complex condition multiplemulti where condition in laravelhow to apply multiple where condition in laravelmultiple orwhere laravelwherein multiple array clause in laravellaravel eloquent multiple whereslaravel where multiple where on one column2 like conditions in same laravelmultiple relationship laravel where conditionlaravel multiple where andlaravel eloquent where with two conditionlaravel where condidion in modellaravel 6 multiple whereeloquent chaining whereeloquent where multiple columnslaravel find multiple conditionsand in where clause laravel ormlaravel where multiple ormultiple orwhere laravel codeigniterlaravel scope multiple where conditionlaravel multiple where and ormultiple andwhereins laraveltwo where laravel2 where condition in laravel querylaravel eloquent multiple where or and one and condition laravel query multiple wherelaravel select where with two conditioncombined where condition laravellaravel where with many conditionslaravel where nultiplelaravel multiple oflaravel controller where equals two valuesmultiple where condition in sql laravellaravel db select multiple wheretwo conditions in where clause laravel db 3a 3alaravel where with two conditionget two type of data in where laravelmulti where condition sql laraveleloquent get where more than two resultsorwhere multiple conditions laravel select with multiple where clause in laraveleloquent where two conditionslaravel orwhere with multiple wherelaravel more than two where conditionlaravel 2beloquent 2badd two where closelaravel query with multiple or conditionlaravel multiwherelaravel multiple where clauselaravel multiple canlaravel sql query 2 where clausesmore than one condition in where laravel multiple conditions in where laravel eloquentmultiple where in query laravelmultiple where statements laravel eloquentmultiple where condition eloquent querymultiple where condition in laravel using looplaravel where many conditioneloquent and whereeloquent where conditionlaravel orwhere conditionlaravel multiple relationships with conditionlaravel query with 2 conditionstwo conditions laravelmultiple condition laravel whenlaravel multiple where conditions same columnwhere clause for multiple value in laravelhow to use multiple where condition in laravellaravel where and or conditionlaravel 8 where or multiple conditionhow to set multiwhere condition in laravel controllereloquent laravel multiple where clause 3alaravel multiple name in where condition how to check for two conditions in laravel using where querywhere condition in laravel multiple condtionseloquent andwheremodel where 2 condition laravellaravel multiple row query and table with multiple conditionslaravel database query when method multiple conditionscheck multiple condition in sql laravel 8how to check multiple conditions in where with or clause in laravellaravel multiple where whenmultiple with in laravel query builderhow to apply multiple select with or condition in laraveluse where in condition eloquent2 conditions in where laravelmultiple where statements laravellaravel orwhere multipletwo condition in laravel modellaravel with multiple modelslaravel 8 2 where conditionseloquent two or wheremultiple where condition in laravel query builder for multiple tablelaravel where or multiplehow to check multiple conditions in where clause in laravelselect 2 where conditions db 3a 3a where 28 29 laravellaravel 2 wheremultiple andwhere condition in laraveleloquent where multiple conditionslaravel queries multiple whereselqquent multiple wheremultiple where clause laravellaravel query multiple rowslaravel where multiple if conditionlaravel two where conditions 23multiple 26 26 in laravel eloquentlaravel multiple clause with or conditionwhere 2 condition laravel orlaravel multiple where statements sqllaravel where 2 conditions ormultiple conditional orm laravel querylaravel eloquent multiple where and ormultiple where and wherein laravelwhere condition in laravel eloquentand where condition in laravellaravel eloquent where andsselect specific field using multi condition in laravelmultiple where with and condition in orm laravelcheck two conditions in where clause laravelmultiple where condition in laravel ormwhere multiple value eloquenthow to use two where condition in one statement in laravelget doble laravellaravel multiple where clause 3alaravel multiple condition in relationshiplaravel mysql orwheremultiple or where laravellaravel where 2 conditionslaravel multiple whereinmultiple where conditionals laravel eloquentmultipke where cluses in laravel controllersmore condition in laravel multiple where condition in laravel 7fetch from database using many conditions laravellaravel model with where clauselaravel eloquent double wherelaravel query many whereorwhere condition in laravelmultiple where in one where laravelhow to write two where clause in laravellaravel query builder multiple orwherewhere on multiple columns and condition laravelorwhere multiple value laravellaravel query builder multiple conditionslarav multiple wherelaravel multiple wherein conditionwhere or with multiple where laravel eloquentlaravel equivalent model where multiple conditionslaravel eloquent where conditionlaravel one field multiple conditionlaravel where with two conditions2 where condition in laravel 1 orwherehow to add multiple conditions in where clause in php laravel query builderhow to give where clause in laraveltwo condition in one laravel querylaravel where with 2 conditionswhere multiple conditions laravellaravel when condition multiple laravel eloquent check two conditionlaravel where or where multipleuse multiple conditions in one where clause laravel eloquentwhere laravel multipleeloquent where multiple conditions with same columnlaravel do two where with andlaravel model multiple wheredb 3a 3aselect multiple where laravelquery with wherer condition larvelusng two ehere connditions in eloquentmultiple condition in laravel eloquenthow to add multiple where condition in laraveladd two or conditions in one laravel wheremultiple value in where clause laravelor on clause laravellaravel eloquent two orwhere clauseslaravel two where conditions on same columnwhere condition laravel eloquentmultiple where and condition in laravel eloquentlaravel mysql how to use clause where for multiple checkhow to write two where condition in laravellaravel where multiple conditions