Get content from Database when relationship (pivot table) exists

Posted 9 months ago by Kunzilla

Hi there,

i build a small project to post as post, follow other users and see them posts - when they are friends / follows.

I have three tables (simplified)

// posts

// users

// relations (i create two inserts a -> b, b -> a)
is_active (the requested user must approve the request)

To get the posts from one user is no problem. But how can i get the data when these relationships are "active"? Keep in mind: The relationship must be approved. I know how i setup the database etc., but i stuck on the part when i check "these two users are friends, get the data".

When a user have 100 friends, it must get the posts from all friend, there are active.

Hope you can help.

Please sign in or create an account to participate in this conversation.

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up


Reply to

Use Markdown with GitHub-flavored code blocks.