I have the following which works perfect but if I want to also bring another data like the user_id that is inside the same table where I do the count it gives me an error. Alquilen knows what the solution might be?
public function scopeCantidadclientes($arvg){
return $arvg->select(DB::raw('count(credito_id) as cantidad'),'credito_id')
->groupBy('credito_id')
->get(); }