'using WHERE condition1 AND condition2 in ::selectraw

I am using ::selectRaw inside my PHP function and I need that statement to get two conditions. In my case, I am using my category_id column

I tried to do two where but seems like these conflict with each other:

    $query = self::selectRaw((is_array($fields)?implode(", ",$fields):$fields))
                   ->where('category_id', '=', 1)
                   ->where('category_id', '=', 2)
                   ->where(function($q) use($search){
        if($search){
            return $q->where(['group_name' => $search]);
        }
    });

how do I translate WHERE category_id = 1 AND category_id = 2 in the ::selectRaw query?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source