two condition in one laravel query

Solutions on MaxInterview for two condition in one laravel query by the best coders in the world

showing results for - "two condition in one laravel query"
Matteo
15 Jan 2018
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    }
Tim
05 Jun 2020
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})
Sara Sofía
05 Jun 2020
1 $data = Sub_sub_category::select('sub_sub_cat_name','id')->where('sub_cat_id',$request->id)->where('status','1')->get();
queries leading to this page
multiple where laravel andwheremultiple where condition laravellaravel multiple or wherelaravel query builder multiple where conditionswhere with multiple conditions laravellaravel where and or conditionlaravel have two where conditionsget two data with different conditions in laravelhow to make a two where in one query in laravel2 with 28 29 execute with different where condition in laravelmultiple where clause in laravelmultiple where condition in sql laravel with if elsemultiple value in where clause laravelorwhere multiple where laravellaravel database query when method multiple conditionslaravel where with 2 conditions truelaravel multiple whereinlaravel where 2 conditions ormultiple or where laravellaravel scope multiple where conditionlaravel multiple and where querylaravel two where conditions 23eloquent where multiple or conditionscan i use two where statement laravelhow to use orwhere in laravel with multiple where conditionhow to have multiple conditions in eloquent laravellaravel multiple wheremultiple where and orwhere in laravelmultiple where condition using if in laravelmultiple where clause laravel in one whereorwhere with more conditions laravelselect query based on a column in laravel multiple conditionlaravel multiple statementsmultiple where exists laravelmultiple when in laravel querymultiple conditions laravel querymultiple where condition in laravel eloquentlaravel search query with multiple conditionsmultiple where in sql query laravellaravel 2 condition in a wherewhere multiple conditions equivalent laraveltwo conditional where with and in laravel eloquentlaravel multiple where statementslaravel eloquent multiple orwherequery multiple condition laravellaravel more than one where conditionmultiple condition where laravelinside where using 2 condition in laravelmultiple where conditionals laravel eloquentlaravel firstwhere multiple and conditionswhere 2 condition laravel or multiple where clause in select laravellaravel where with multiple conditionsmultiple where inside where or laravellaravel query builder multiple conditionslaravel find multiple conditions2 conditions in where laravelmultiple where statements laravelwhere with multiple conditions and or laravellaravel query with multiple wheremultiple orwhere laravelorwhere multiple conditions laravelmultiple orwhere laravel codeignitermultiple where with and condition in orm laravelmultiple where clause in laravel 8laravel where multiple conditionslaravel multiple with or wheremultiple conditions in laravel wherehow to add multiple conditions in where clause in php laravel query builder2 condition in laravel2 conditions in laravel query buildermultiple where laravel 8laravel using two wherelaravel where multiple valueshow condition for multiple row by orwhere laravelwhere condition eloquent multiplehow to apply multiple select with or condition in laravelhow to use multiple where condition in laravelthird tables condition in laravel eloquentlaravel query multiple rowslaravel eloquent where two conditionstwo where clause in laravelmultiple relationship laravel where conditionto check multiple condition in where condition in laravel databasewhere multi condition laravelmultiple where condition in sql laravellaravel query multiple where laravel mutliple condition in where clauseusing multiple where in laravellaravel firstwhere multiple conditionslaravel orwhere multiplelaravel multiple with functionmultiple orwhere condition in laraveltwo where condition in laravellaravel multiple where conditionhow to use multiple condition in laravellaravel multiple where clausemultiple where condition in laravel using loopwhere with two conditions in laravelmultiple with clause in laravelmultiple logical condition in laravel querymultiple where condition in laravel 8laravel where 2 conditionsmultiple where condition eloquent querytwo statement in where method laravelhow to check for two conditions in laravel using where querylaravel where two conditionsmultiple tables where in laravelmore than one condition in where laravel laravel eloquent multiple where conditionwhere two conditions laravellaravel where or multiplelaravel where clause with multiple conditionsmultiple and or where clause laravel eloquentmultiple where condition in laravel as arraylaravel query whereor check two conditionslaravel multiple relationships with conditionquery where with two conditions laravellaravel where with or conditionhow to use two where condition in one statement in laravelorwhere condition in laravellaravel multiple orwheremultiple statement in where laravelinside where using 2 condition i laravel laravel query with two where with two diferents tablelaravel where more than one and conditionmultiple where condition in laraveltwo select statements in one query laravellaravel multiple wherein columnsorwhere laravel two conditionsorwhere multiple value laravellaravel where multiple select datatablesmultiple where query in laraveltwo condition in where in laravellaravel query builder multiple orwherelaravel query multiple conditionsmultiple condition where laravel 7where with two conditions laraveltwo condition in one laravel querylaravel orwhere with multiple wheremultiple where condition in laravel ormlaravel where multiple orwhere multiple conditions sql laravelwhere condition with matching multiple elements query laravellaravel two database conditionhow to use two where condition in laraveltwo where but or condition in laravellaravel query with multiple or conditionlaravel query with two wherelaravel where with two conditionsmultiple orwhere in laravellaravel orm with multiple conditionlaravel where or where multiplelaravel multiple with use to where has query unmultiple when condition laraveluse multiple where clause and not in condition in laraveluse one query in two query laravel select with multiple where clause in laravelmultiple where clause in laravel eloquenteloquent where with multiple conditionslaravel mysql orwherelaravel two where conditionslaravel when condition multiple multiple where condition in laravel querytwo conditions in query builder laravellaravel db query with two conditionsusing multiple where in laravel with conditionmore than 2 where conditions in laravelcheck multiple conditions in where clause laravel ormlaravel multiple and or where conditionslaravel multiple where and orlaravel where condition multiple matchmultiple where clause laraveltwo condition in where mysql laravelmultiple conditions in where laravellaravel model multiple where and orwheremultiple where and andwherein laraveltwo conditions in where clause laravel db 3a 3ahow to multiple where condition in laravelwhere 2 condition laravelfetch from database using many conditions laravelquery for multiple condition coumns laravelmultiple conditional orm laravel querymultiple condition in where laravelmultiple where condition in laravel query buildermultiple where statements laravel eloquenthow to check multiple conditions in where with or clause in laravellaravel multiple where andmultiple query make single in laravellaravel where clause with multiple conditions not equalmultiple orwheres laravellaravel multiple where and orwheremultiple where condition in eloqunt laravel2 or more with laravel relationship conditionlaravel multiple condition on joinhow to make multiple where condition in laravelquery for multiple where clauses laraveltwo where condition with and in laravellaravel multiple orwhere and and not workinglaravel php 8 multiple where conditionwhere clause for multiple value in laravelmultiple if condition in laravel querylaravel multiple condition in relationshipselect from database in laravel with two conditionswhere multiple conditions laravelmultiple where condition in laravel 7multiple wheres laravelmulti condition in where laravelhow to select multiple where conditions in laravel sql querymulti orwhere laravelmultiple where and condition in laravel eloquent2 where condition in laravel 1 orwherehow to check multiple conditions in where clause in laravelhow to use multiple where condition in laravel eloquentlaravel eloquent multiple where and orwherelaravel 8 where or multiple conditionmultiple where clause laravellmultiple and or condition in laravel blademultiple condition in laravel wheremultiple where clause eloquent laravellaravel when for two where clauselaravel multiple canlaravel where 2 conditionhow to write two where condition in laravelmore then one condition in laravel elequent querylaravel more than two where conditionlaravel orwhere conditionhow to to apply multiple where condition in laravelmultiple where in laravelmultiple where condition in where clause in laravelcheck multiple condition in sql laravel 8eloquent multiple orwhereall 28 29 3b with two condition in laravellaravel eloquent query with multiple conditionslaravel multiple name in where condition check multiple where condition in laravelmultiple where and wherein laravelquery where with two and conditions laravelmultiple 26 26 in laravel eloquenteloquent multiples where and orwheremultiple condition laravel whenget two or more clause query in laravellaravel multiple wherein conditionlaravel two where clauselaravel eloquent where with two conditionlaravel having multiple conditionseloquent where multiple conditionsmultiple andwhere condition in laravelmultiple where conditions elequentlaravel two where conditions with eloquentfind with multiple conditions in laraveltwo condition in one laravel query