Tuesday, May 23, 2017

Laravel eloquent orm query using orwhere clause

Hi I have been using this query to retrieve data based on orWhere clause

$q->where('created', $date);
$q->where(function ($query) {
  $query->where('gender', 'Male')
        ->where('age', '>=', 18);
})->orWhere(function($query) {
  $query->where('gender', 'Female')
        ->where('age', '>=', 30);   
})->orWhere(function($query) {
  $query->where('gender', 'Orthodox')
        ->where('age', '>=', 35);

first orWhere clause is working perfectly, however 2nd isnt. It seems to be a scope issue, i.e something with ()



via h_a86

Advertisement