Can't export with belongsToMany relationship #3372
-
Hello, Trying to export my hotels collection in excel file, where I should have hotel name and hotel services, which is a many to many relationship. This is how my HotelsExport.php file looks like:
I'm getting this error:
I tried to add relationship into collection function, but didn't work for me:
Without services, export works just fine, but I need services also, that's really important. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
|
Beta Was this translation helpful? Give feedback.
$hotel->services->name
this won't work in normal Laravel either, not something package specific.services
is a collection, so you would need to get all names and e.g. comma separate them.