I've huge concern about my Eloquent based application. Let me write my model structure. I've Post, Group and User model. Group is polymorphic model that has belongsToMany relation with both User and Post models. For both User and Post model, it'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 show on the Posts::get();
action.
Post Model: id | name | content
Group Model id | name
User Model id | username
user_groups: pivot table user_id | group_id
post_groups: pivot table post_id | group_id
I know it can be done with collection filter. But it's not best practice for this case. I am really want how to do it on query builder side.