3 years ago

Does Eloquent prepare the output of the data in the collection when relationships are eager loaded?

Posted 3 years ago by Ruffles

Hello there!

I am working on this project where I use the Fluent Query Builder and I am trying to recreate the same output from the eloquent relationship eager loading, User::with('roles')->get() for example, with join statements.

As a result I had duplicate rows for obvious reasons. I had a list of repeating email addresses with multiple role names for a many to many relationship.

My question is: Do I have to manually structure the objects where I have a nested object(s) for the relationships?

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