Skip to content

Including and excluding properties when using the collect() method? #791

Discussion options

You must be logged in to vote

Since collect outputs the same type as it gets fed, the following:

SongData::collect(Song::all())->include('name');

Will return an Eloquent collection which doesn't support includes. Try the following:

SongData::collect(Song::all(), DataCollection::class)->include('name');

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@jonjakoblich
Comment options

@rubenvanassche
Comment options

Answer selected by jonjakoblich
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants