简体   繁体   中英

Using a Laravel 5 / Eloquent where statement to find an object's relational object

I have an object called 'Notification'. 'Notification' is related to another object called 'NotificationGroup' through a one to many relation (A NotificationGroup can own many Notifications). A 'NotificationGroup' belongs to another object called 'Organisation' in a similar way (An Organisation can own many NotificationGroups).

Using a where statement, would it be possible to grab all the Notifications that belong to an Organisation.

I apologise for the long-winded question, but I cannot find examples of this anywhere, nor if this type of thing is possible.

使用Don'tPanic的信息,我使用了“ hasManyThrough”关系并创建了此语句。

$this->hasManyThrough('App\Models\Notification', 'App\Models\NotificationGroup',  'organisation', 'notificationGroup')->get();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM