Including and excluding properties when using the collect() method? #791
-
How can I include a Lazy property on when creating a collection of data objects? I understand from the docs that this works (assume property 'name' is Lazy).
But, because this returns a Collection, the following code will not work.
What ae my options for including Lazy properties with collections? I am working with v4. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Since collect outputs the same type as it gets fed, the following:
Will return an Eloquent collection which doesn't support includes. Try the following: SongData::collect(Song::all(), DataCollection::class)->include('name'); |
Beta Was this translation helpful? Give feedback.
Since collect outputs the same type as it gets fed, the following:
Will return an Eloquent collection which doesn't support includes. Try the following: