| Methods |
public
|
find<TFindDefault>(
mixed $key,
TFindDefault $default = null,
): ($key is Arrayable<array-key, mixed>|array<mixed> ? static : TModel|TFindDefault)
Find a model in the collection by key.
Find a model in the collection by key.
|
#
|
public
|
findOrFail(mixed $key): TModel
Find a model in the collection by key or throw an exception.
Find a model in the collection by key or throw an exception.
Throws
|
#
|
public
|
load(array<array-key, array|(callable(Relation<*, *, *>): mixed)|string>|string $relations): $this
Load a set of relationships onto the collection.
Load a set of relationships onto the collection.
|
#
|
public
|
loadAggregate(
array<array-key, array|(callable(Relation<*, *, *>): mixed)|string>|string $relations,
string $column,
string|null $function = null,
): $this
Load a set of aggregations over relationship's column onto the collection.
Load a set of aggregations over relationship's column onto the collection.
|
#
|
public
|
loadCount(array<array-key, array|(callable(Relation<*, *, *>): mixed)|string>|string $relations): $this
Load a set of relationship counts onto the collection.
Load a set of relationship counts onto the collection.
|
#
|
public
|
loadMax(array<array-key, array|(callable(Relation<*, *, *>): mixed)|string>|string $relations, string $column): $this
Load a set of relationship's max column values onto the collection.
Load a set of relationship's max column values onto the collection.
|
#
|
public
|
loadMin(array<array-key, array|(callable(Relation<*, *, *>): mixed)|string>|string $relations, string $column): $this
Load a set of relationship's min column values onto the collection.
Load a set of relationship's min column values onto the collection.
|
#
|
public
|
loadSum(array<array-key, array|(callable(Relation<*, *, *>): mixed)|string>|string $relations, string $column): $this
Load a set of relationship's column summations onto the collection.
Load a set of relationship's column summations onto the collection.
|
#
|
public
|
loadAvg(array<array-key, array|(callable(Relation<*, *, *>): mixed)|string>|string $relations, string $column): $this
Load a set of relationship's average column values onto the collection.
Load a set of relationship's average column values onto the collection.
|
#
|
public
|
loadExists(array<array-key, array|(callable(Relation<*, *, *>): mixed)|string>|string $relations): $this
Load a set of related existences onto the collection.
Load a set of related existences onto the collection.
|
#
|
public
|
loadMissing(array<array-key, array|(callable(Relation<*, *, *>): mixed)|string>|string $relations): $this
Load a set of relationships onto the collection if they are not already eager loaded.
Load a set of relationships onto the collection if they are not already eager loaded.
|
#
|
public
|
loadMissingRelationshipChain(array $tuples): void
Load a relationship path for models of the given type if it is not already eager loaded.
Load a relationship path for models of the given type if it is not already eager loaded.
|
#
|
protected
|
loadMissingRelation(Collection<int, TModel> $models, array $path): void
Load a relationship path if it is not already eager loaded.
Load a relationship path if it is not already eager loaded.
|
#
|
public
|
loadMorph(string $relation, array<array-key, array|(callable(Relation<*, *, *>): mixed)|string> $relations): $this
Load a set of relationships onto the mixed relationship collection.
Load a set of relationships onto the mixed relationship collection.
|
#
|
public
|
loadMorphCount(string $relation, array<array-key, array|(callable(Relation<*, *, *>): mixed)|string> $relations): $this
Load a set of relationship counts onto the mixed relationship collection.
Load a set of relationship counts onto the mixed relationship collection.
|
#
|
public
|
contains((callable(TModel, TKey): bool)|TModel|string|int $key, mixed $operator = null, mixed $value = null): bool
Determine if a key exists in the collection.
Determine if a key exists in the collection.
Overrides
|
#
|
public
|
doesntContain((callable(TModel, TKey): bool)|TModel|string|int $key, mixed $operator = null, mixed $value = null): bool
Determine if a key does not exist in the collection.
Determine if a key does not exist in the collection.
Overrides
|
#
|
public
|
modelKeys(): array<int, array-key>
Get the array of primary keys.
Get the array of primary keys.
|
#
|
public
|
merge(iterable<array-key, TModel> $items): static
Merge the collection with the given items.
Merge the collection with the given items.
Overrides
|
#
|
public
|
map<TMapValue>(callable(TModel, TKey): TMapValue $callback): Collection<TKey, TMapValue>|static<TKey, TMapValue>
Run a map over each of the items.
Run a map over each of the items.
Overrides
|
#
|
public
|
mapWithKeys<TMapWithKeysKey is array-key, TMapWithKeysValue>(
callable(TModel, TKey): array<TMapWithKeysKey, TMapWithKeysValue> $callback,
): Collection<TMapWithKeysKey, TMapWithKeysValue>|static<TMapWithKeysKey, TMapWithKeysValue>
Run an associative map over each of the items.
Run an associative map over each of the items.
The callback should return an associative array with a single key / value pair.
Overrides
|
#
|
public
|
fresh(array<array-key, string>|string $with = []): static
Reload a fresh model instance from the database for all the entities.
Reload a fresh model instance from the database for all the entities.
|
#
|
public
|
diff(iterable<array-key, TModel> $items): static
Diff the collection with the given items.
Diff the collection with the given items.
Overrides
|
#
|
public
|
intersect(iterable<array-key, TModel> $items): static
Intersect the collection with the given items.
Intersect the collection with the given items.
Overrides
|
#
|
public
|
unique((callable(TModel, TKey): mixed)|string|null $key = null, bool $strict = false): static
Return only unique items from the collection.
Return only unique items from the collection.
Overrides
|
#
|
public
|
only(array<array-key, mixed>|null $keys): static
Returns only the models from the collection with the specified keys.
Returns only the models from the collection with the specified keys.
Overrides
|
#
|
public
|
except(array<array-key, mixed>|null $keys): static
Returns all models in the collection except the models with specified keys.
Returns all models in the collection except the models with specified keys.
Overrides
|
#
|
public
|
makeHidden(array<array-key, string>|string $attributes): $this
Make the given, typically visible, attributes hidden across the entire collection.
Make the given, typically visible, attributes hidden across the entire collection.
|
#
|
public
|
mergeHidden(array<array-key, string>|string $attributes): $this
Merge the given, typically visible, attributes hidden across the entire collection.
Merge the given, typically visible, attributes hidden across the entire collection.
|
#
|
public
|
setHidden(array<int, string> $hidden): $this
Set the hidden attributes across the entire collection.
Set the hidden attributes across the entire collection.
|
#
|
public
|
makeVisible(array<array-key, string>|string $attributes): $this
Make the given, typically hidden, attributes visible across the entire collection.
Make the given, typically hidden, attributes visible across the entire collection.
|
#
|
public
|
mergeVisible(array<array-key, string>|string $attributes): $this
Merge the given, typically hidden, attributes visible across the entire collection.
Merge the given, typically hidden, attributes visible across the entire collection.
|
#
|
public
|
setVisible(array<int, string> $visible): $this
Set the visible attributes across the entire collection.
Set the visible attributes across the entire collection.
|
#
|
public
|
append(array<array-key, string>|string $attributes): $this
Append an attribute across the entire collection.
Append an attribute across the entire collection.
|
#
|
public
|
setAppends(array<array-key, mixed> $appends): $this
Sets the appends on every element of the collection, overwriting the existing appends for each.
Sets the appends on every element of the collection, overwriting the existing appends for each.
|
#
|
public
|
withoutAppends(): $this
Remove appended properties from every element in the collection.
Remove appended properties from every element in the collection.
|
#
|
public
|
getDictionary(iterable<array-key, TModel>|null $items = null): array<array-key, TModel>
Get a dictionary keyed by primary keys.
Get a dictionary keyed by primary keys.
|
#
|
public
|
countBy($countBy = null): Collection<array-key, int>
{@inheritDoc}
|
#
|
public
|
collapse(): Collection<int, mixed>
{@inheritDoc}
|
#
|
public
|
flatten($depth = INF): Collection<int, mixed>
{@inheritDoc}
|
#
|
public
|
flip(): Collection<TModel, TKey>
{@inheritDoc}
|
#
|
public
|
keys(): Collection<int, TKey>
{@inheritDoc}
|
#
|
public
|
pad<TPadValue>($size, $value): Collection<int, TModel|TPadValue>
{@inheritDoc}
|
#
|
public
|
partition($key, $operator = null, $value = null): Collection<int<0, 1>, static<TKey, TModel>>
{@inheritDoc}
|
#
|
public
|
pluck($value, $key = null): Collection<array-key, mixed>
{@inheritDoc}
|
#
|
public
|
zip<TZipValue>($items): Collection<int, Collection<int, TModel|TZipValue>>
{@inheritDoc}
|
#
|
protected
|
duplicateComparator($strict): callable(TModel, TModel): bool
Get the comparison function to detect duplicates.
Get the comparison function to detect duplicates.
Overrides
|
#
|
public
|
withRelationshipAutoloading(): $this
Enable relationship autoloading for all models in this collection.
Enable relationship autoloading for all models in this collection.
|
#
|
public
|
getQueueableClass(): string|null
Get the type of the entities being queued.
Get the type of the entities being queued.
Throws
Implements
|
#
|
protected
|
getQueueableModelClass(Model $model): string
Get the queueable class name for the given model.
Get the queueable class name for the given model.
|
#
|
public
|
getQueueableIds(): array<int, mixed>
Get the identifiers for all of the entities.
Get the identifiers for all of the entities.
Implements
|
#
|
public
|
getQueueableRelations(): array<int, string>
Get the relationships of the entities being queued.
Get the relationships of the entities being queued.
Implements
|
#
|
public
|
getQueueableConnection(): string|null
Get the connection of the entities being queued.
Get the connection of the entities being queued.
Throws
Implements
|
#
|
public
|
toQuery(): Builder<TModel>
Get the Eloquent query builder from the collection.
Get the Eloquent query builder from the collection.
Throws
|
#
|