Laravel Tips: Raw DB Queries: havingRaw() [5]

You can use RAW DB queries in various places, including ​havingRaw()​ function after groupBy()​.

Product::groupBy('category_id')->havingRaw('COUNT(*) > 1')->get();