【发布时间】:2020-11-24 02:13:37
【问题描述】:
我正在尝试使用取决于通知模型值的关系来急切加载用户的通知:
$notifications = $user->notifications()
->with([
'notifiable' => function ($query) {
// Only load notifiable relation if notification 'notifiable_type' equals...
},
'notifiable.group:id,title' => function ($query) {
// Only load notifiable.group:id,title relation if notification 'notifiable_type' equals...
}
])
->get();
问题是闭包中的$query 正在查询notifiable 关系而不是通知模型本身......我显然错过了一些非常微不足道的东西。有什么建议吗?
【问题讨论】:
-
@BhaumikPandhi 不,它没有