Introduction
When Eloquent returns more than one model, you receive anIlluminate\Database\Eloquent\Collection.It extends
Illuminate\Support\Collection, so you inherit the full base collection API plus model-specific helpers.
Available methods
Eloquent\Collection inherits all base collection methods and adds model-focused methods.
append / withoutAppends / setAppends
Control appended attributes for every model in the collection.
contains / diff / except / intersect / only
Check membership and perform set operations using model instances or primary keys.
find / findOrFail
Find already-loaded models by primary key.
fresh
Re-fetch each model in the collection from the database, optionally eager loading relations.
load / loadMissing
Eager load relationships on a collection after retrieval.
modelKeys
Get the primary keys for all models in the collection.
makeVisible / makeHidden / mergeVisible / mergeHidden / setVisible / setHidden
Adjust attribute visibility for serialization across the entire model collection.
partition
Split models into two Eloquent\Collection instances; the outer container is an Illuminate\Support\Collection.
toQuery
Build a whereIn query from already-loaded model keys and perform one bulk operation.
unique
Remove duplicated models that share the same primary key.
Eloquent-to-base collection conversion
collapse, flatten, flip, keys, pluck, and zip return an Illuminate\Support\Collection.Likewise,
map returns a base collection when the mapped result no longer contains Eloquent models.
Custom collections
If you want model-specific collection behavior, prefer the#[CollectedBy] attribute first.
#[CollectedBy] attribute (preferred)
newCollection() method (alternative)
newCollection() or #[CollectedBy], Eloquent returns your custom collection wherever it would normally return Illuminate\Database\Eloquent\Collection.
Related pages
Collections
Review
Illuminate\\Support\\Collection fundamentals.Eloquent ORM
Revisit Eloquent model and query basics.