如何过滤嵌入的结果很多关系?

时间:2015-09-29 16:07:03

标签: php mongodb laravel eloquent

我对这个概念有困难。

我有Path: [C:\config\test.properties] Can.Path: [C:\config\test.properties] Exists? false CanRead? false Dir? false java.io.FileNotFoundException: C:\config\test.properties (The system cannot find the path specified) at java.io.FileInputStream.open0(Native Method) at java.io.FileInputStream.open(Unknown Source) at java.io.FileInputStream.<init>(Unknown Source) at com.gallup.gtm.core.server.database.DatabaseConnection.main(DatabaseConnection.java:40) UserhasMany

我的OrganizationUserOrganizationUserembedsMany

在我的代码中,我可以通过以下方式返回Notification&#39; User

OrganizationUsers

这将在我的$user = Auth::user(); $user->organizationUsers; return $user; 对象上返回属性organization_users,该对象是user的数组。

现在,我想返回每个OrganizationUsers的{​​{1}}。

起初,我做了以下工作,效果很好:

Notifications

这会在OrganizationUser数组中的每个对象上附加$user = Auth::user(); $user->organizationUsers; for ($i = 0; $i < $user->organizationUsers->count(); $i++) { $user->organizationUsers[$i]->notifications; } return $user; 数组。

但是,我想通过notifications属性过滤这些结果。

我尝试了以下内容:

organization_users

然而,这根本不会过滤。我试过了:

resolved

但这并没有像我希望的那样返回数组,相反,通知数组是&#34;索引&#34;:

for ($i = 0; $i < $user->organizationUsers->count(); $i++) {
    $user->organizationUsers[$i]->notifications->where('resolved', false)->get();
}

它似乎返回了一个对象而不是一个对象数组。有什么想法吗?

0 个答案:

没有答案
相关问题