Skip to content
Advertisement

Laravel I can’t retrieve requester data using with

I am using this package https://github.com/renoki-co/befriended My issue is trying to get all my friends posts with my post including user’s data, but the problem is the requester data is null.

JavaScript

Response

JavaScript

As you can see the first object in the array dosen’t include the user data. So what should i do $query->filterFollowingsOf($user); to include my data?

Advertisement

Answer

I think the with callback is used for modifying the query that selects the user data. Instead, try using a whereHas method that filters the related users.

JavaScript

I’d also recommend using paginate() instead of get() for performance when there could be a significant number of posts.

Edit:

To get either your friend’s posts or your posts, try:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement