I'm trying to use a WHERE IN statement in the query builder using whereRaw but it doesn't seem to work. I'm not trying to select values from other tables though, just selecting from multiple values.
I've tried these 3 approaches:
return $this->object->whereRaw("`status` = 'active' AND `salesType` IN ( ? ) AND `region_id` = ?", array("'sale','buy'","1"))->paginate(10);
return $this->object->whereRaw("`status` = 'active' AND `salesType` IN ( ? ) AND `region_id` = ?", array("sale,buy","1"))->paginate(10);
return $this->object->whereRaw("`status` = 'active' AND `salesType` IN ( ? ) AND `region_id` = ?", array(array("sale,buy"),"1"))->paginate(10);
Why don't you use where
and whereIn` methods?
return $this->object->where('status', '=', $active)->whereIn('salesType', $array);