i have tow models Userand Driver the user can register any number of drivers drivers
in drivers table i have agent_id, i want to list all the users with the count of the drivers they registered
in my Usercontroller i want to get the count of the drivers registered by the agents
public function index(Request $request)
{
$users = User::all();
$registration_centers = RegistrationCenter::all();
$drivers_registered = Driver::where('agent_id' , $agent_id)->count(); //something like this but i don't have agent_id to query with
return view('agents', compact('users', 'registration_centers', drivers_registered));
}
thank you
Aucun commentaire:
Enregistrer un commentaire