在我的应用程序中,我已经将关系从one-to-many
更新到many-to-many
,并且我正在试图找出一种持久保存相关功能的方法.
Let's say I have two related tables, e.g. dogs and owners. If I have an array of owners and I'm trying to get a list of dogs id's for those owners, how should I do it eloquently?
这里也提出了类似的问题:
So, How would I get the Dog
models where Owner
is in an array ?
Same thing as $associatedDogs = Dog::whereIn('owner_id',$ListOfOwners)->get();
is for a One-To-Many
relationship, but for Many-to-Many
.