我've huge concern about my Eloquent based application. Let me write my model structure. I' ve邮政,团体和用户模型 . Group是与User和Post模型属于ToMany关系的多态模型 . 对于User和Post模型,它在 Posts::get(); 动作上显示's not required to have group. Both can be or cannot be able to have groups. What I want to do is, if logged in user is not member of the group of post, it won't .

Post Model: id |名字|内容

Group Model id |名称

User Model id |用户名

user_groups: pivot table user_id | GROUP_ID

post_groups: pivot table post_id | GROUP_ID

我知道它可以用收集过滤器完成 . 但对于这种情况来说,这不是最好的做法 . 我真的想在查询生成器方面如何做到这一点 .