Yes, you just insert the block that you want to execute as a function .... according to the documentation Grouping parameters , you can do it like this ... passing the function Where a ...
This code below will probably not do what you want, but, there is something for you to build and play with.
DB::table('users') ->where('name', '=', 'John') ->orWhere(function($query) { $query->group_by($value); ->select(DB::raw('COUNT('.$value.') as count')); }) ->get();
Kylek source share