$query->where([
['column_1', '=', 'value_1'],
['column_2', '<>', 'value_2'],
[COLUMN, OPERATOR, VALUE],
...
])
// ...
$q->where(function ($query) {
$query->where('gender', 'Male')
->where('age', '>=', 18);
})->orWhere(function($query) {
$query->where('gender', 'Female')
->where('age', '>=', 65);
})
//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}%");
}
});
$data = Sub_sub_category::select('sub_sub_cat_name','id')->where('sub_cat_id',$request->id)->where('status','1')->get();