Answer the question
In order to leave comments, you need to log in
M:n in Laravel 5.4 controllers?
Good day to all.
Need support in many to many relationships in laravel.
Next scenario.
There is a network of shops
shops:
id
name
..
there are entrepreneurs:
id
name
..
there is an m:n connection between them, while shops can exist without entrepreneurs and vice versa.
There is a Customer controller
public function locationByCustomer(Customer $customer)
{
$customer->shops(); //Shop-Model -> belongsToMany(Customer)
return $customer;
}
select id, name from shops where id not in (select shop_id from shop_customer)
Answer the question
In order to leave comments, you need to log in
If I understand the question correctly, then:$shops = Shop::doesntHave('customer')->get();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question