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

PREVIOUS NEXT
Code Example
Php :: php json request get value of an array element 
Php :: eloquent limit vs take 
Php :: how to display the taxonomy image in wordpress 
Php :: foreach loop laravel 
Php :: php requuire once 
Php :: mkdir permission denied php 
Php :: laravel wher in 
Php :: php export excel 
Php :: twig is in string 
Php :: clear array php 
Php :: how to find total rows fetched php pdo 
Php :: php send telegram message to user 
Php :: php sort multi dimensional array 
Php :: get am pm 12 hour timee laravel 
Php :: how to limit word in php 
Php :: wordpress custom post type add post_tag 
Php :: create a text file in laravel 
Php :: read pdf text in php 
Php :: how to call a helper function in blade 
Php :: laravel unsigned integer 
Php :: get static front page 
Php :: how remove empty value in array php 
Php :: Regex For Iranian Phone Numbers 
Php :: sending data from one website to another in php 
Php :: offset codeigniter 3 
Php :: current user wordpress 
Php :: eloquent pluck multiple columns 
Php :: laravel custom log 
Php :: php check for null 
Php :: php remove array element 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =