I'm doing a query that will list users with data from multiple tables so I'm using JOIN
.
I've already been able to list user data, what I'm trying to do now is count the number of players that belong to that user I'm listing. I've done everything but you're presenting me with an error that I do not know how to solve.
I count on your help.
Error
Call to undefined method Illuminate \ Database \ Query \ Builder :: group_by ()
Code
class ListaAgentesController extends Controller{
public function lista_agentes (){
$user_id = Auth::user()->id;
$lista_agentes = DB::table('agents')->join('agent_types', 'agent_types.id', '=', 'agents.type')
->join('players', 'players.agent', '=', 'agents.id')
->where('agents.id', '!=', $user_id)
->select('agents.*', 'agent_types.*', 'players.*', 'agents.id as user_id', DB::raw('COUNT(players.id) as count_palyers'))
->group_by('players.id')
->get();
return view('admin.templates.agentes', ['lista_agentes' => $lista_agentes]);
}
}