Polymorphic Many-to-Many relationship 'where' clause on table after pivot
I have a polymorphic many-to-many relationship with posts and videos such that posts or videos are either visible if 'public' or if the user is associated to the post via the peekables pivot table.
posts
id - integer
name - string
visibility - string // e.g. 'private', 'public'
videos
id - integer
name - string
visibility - string // e.g. 'private', 'public'
users
id - integer
name - string
peekables
user_id - integer
peekable_id - integer
peekable_type - string // 'App\Videos' or 'App\Posts'
How do I retrieve the all posts which are either having their visibility set to 'public' or which have a specific user_id associated via the peekables table along with pagination of '5' using Eloquent?