Introduction to Laravel Collections
The
Illuminate\Support\Collection class provides a flexible and convenient wrapper for working with arrays. It allows for fluent mapping and reducing of arrays by chaining methods. Collections are generally immutable; most methods return a new Collection instance rather than modifying the original.$collection = collect(['Taylor', 'Abigail', null])->map(function (?string $name) {
return strtoupper($name);
})->reject(function (string $name) {
return empty($name);
});