The tap() Helper
Call a closure on a value and return the value, not the closure result. Perfect for chaining side-effects without breaking a fluent chain.
Entries tagged with "Collections".
Call a closure on a value and return the value, not the closure result. Perfect for chaining side-effects without breaking a fluent chain.
Expand a flat dot-notation array back into a fully nested structure — the inverse of Arr::dot().
Get exactly one matching item from a collection — or throw an exception. A stricter alternative to first().
Create a sliding window of overlapping chunks from a collection — perfect for moving averages, comparisons, and sequential analysis.
Apply a callback to every element in an array (including nested arrays) without converting to a Collection first.
Convert an Eloquent Collection back into a query builder scoped to those exact model IDs — bridging collections and queries.
Pass an entire collection into a class constructor — transform collection pipelines into domain objects in a single call.