Hello, I'm new on Laravel, and I need some help to build this query. My clients have many contacts, I want to get all clients, but only return the contact marked as main. It´s possible with Eloquent, or I need to use Query. Please if is possible to put a example.
$clients = Client::leftJoin('contacts', function($join) {
$join->on('client.id', '=', 'contacts.client_id');
})
->where('contacts.type','=','main')
->get();
maybe something like this?
Perfectly, thanks for your help!!! Now I understand the concept. Sorry my bad english :)
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community