1
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 the 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 a mistake I don’t know how to fix.
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]);
}
}
Is not
group_by
and yesgroupBy
.– Diego Souza
Fixed the bug but now no longer listing users
– César Sousa
Hence it is already a problem in your query. You have already tried to run this query in your DBMS ?
– Diego Souza
No, you can’t see by my code if I’m doing something wrong ?
– César Sousa
I commented wrong. So I don’t know the structure of your table to tell you what might be wrong. I also don’t know what data needs to be shown. You should see this.
– Diego Souza
Take this query and run on your DBMS.
– Diego Souza
How am I going to run this on mysql if this is readable
– César Sousa
Are you serious ? Convert this into a query for Mysql !
– Diego Souza
Not returning anything in mysql do not know what could be wrong help me
– César Sousa