Search
 
SCRIPT & CODE EXAMPLE
 

PHP

laravel where multiple conditions

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

multiple logical condition in laravel query

// ...
$q->where(function ($query) {
    $query->where('gender', 'Male')
        ->where('age', '>=', 18);
})->orWhere(function($query) {
    $query->where('gender', 'Female')
        ->where('age', '>=', 65);	
})
Comment

laravel where multiple conditions on single colmn

//laravel
// here, i have used two different where condition on a single column
$today = Carbon::today();
$data = Users::where('type',1)
        ->where(function($query) use ($today) {
            return $query->whereDate('updated_at','!=', $today)
            ->orWhere('updated_at',null);
         })
         ->get();

//another example ->
//when you need to use like and in_array functionality together
//when column value is like {tag:active} and you are checking with an array
$query->where(function($query) use ($filter_tags) {
     foreach($filter_tags as $tag){
         $query->orWhere('user.tags', 'LIKE', "%{tag}%");
    }
});
Comment

two condition in one laravel query

 $data = Sub_sub_category::select('sub_sub_cat_name','id')->where('sub_cat_id',$request->id)->where('status','1')->get();
Comment

PREVIOUS NEXT
Code Example
Php :: json_decode object to array 
Php :: foreach stdclass object php 
Php :: Flutter Error - Migrate to android studio - MAC OS 
Php :: image validate in laravel validater 
Php :: laravel set config value dynamically 
Php :: php datum formatieren 
Php :: php uppercase with accent 
Php :: Installation request for phpoffice/phpspreadsheet 1.4.0 - satisfiable by phpoffice/phpspreadsheet[1.4.0] 
Php :: change datetime format from Y-m-d h:i:s to d-m-Y in php 
Php :: php empty array 
Php :: guzzlehttp form data 
Php :: install php 5.6 on ubuntu 18.04 
Php :: create char laravel migration 
Php :: php date first day of month and last month 
Php :: laravel try catch example 
Php :: check variable type in php 
Php :: validation not exist in table laravel 
Php :: regex php password 
Php :: delete bunch of rows in laravel 
Php :: debian php switch version 
Php :: iterating rows in php 
Php :: php append element to array 
Php :: codeigniter 3 or where not in 
Php :: how to send data from one website to another in laravel 
Php :: search function using php for database entries 
Php :: laravel clone row 
Php :: laravel 6 get user id 
Php :: laravel log build custom channel 
Php :: php switch case multiple values per line 
Php :: timezone php 
ADD CONTENT
Topic
Content
Source link
Name
1+7 =