Open gg-aditya opened 1 year ago
@gg-aditya sorry about the delayed reply on this. Instead of
return Moldssp::paginator(Post::with('user'), $request)
can you try to use the below:
return Moldssp::paginator(Post::with(['user']), $request)
This is passing the "with" values as an array instead of a string. So basiscally use square brackets aroung 'users' inside with.
Let me know if this works.
@gg-aditya sorry about the delayed reply on this. Instead of
return Moldssp::paginator(Post::with('user'), $request)
can you try to use the below:
return Moldssp::paginator(Post::with(['user']), $request)
This is passing the "with" values as an array instead of a string. So basiscally use square brackets aroung 'users' inside with.
Let me know if this works.
Hi! Thank you for your response. I tried adding 'square brackets' as you suggested. However, I'm still getting the same result as before. The relationships simply just won't load.
return Moldssp::paginator(Post::with(['user']), $request)
I have two collections (tables) as specified below.
The models are "User" & "Post". The relationships between these two tables are as specified below:
User Model
Post Model
When I try to eager load relationship using the 'with()' method of the eloquent model "Post", the relationship data is simply not loaded.
Code
Response
However, when I eager load the relationship normally without "Moldssp"'s "paginator" method, the relationships get loaded.
Code
Response
Sorry for such a long post. But, I was wondering if you'll be able to fix this issue or maybe provide a workaround for this issue.
Thank you