![Using Maps In Laravel Collections](https://fikretcure.dev/storage/6/using-maps-in-laravel-collections.jpg)
Let's assume that we are recording your records using a model.
$users = User::all();
$uppercasedNames = $users->map(function ($user) {
return strtoupper($user->name);
});
An array data can be processed
$collection = collect([1, 2, 3, 4, 5]);
$mapped = $collection->map(function ($item, $key) {
return $item * 2;
});
Another example
$users = [
['name' => 'John', 'age' => 30],
['name' => 'Alice', 'age' => 25],
['name' => 'Bob', 'age' => 35]
];
$modifiedUsers = collect($users)->map(function ($user) {
return [
'name' => strtoupper($user['name']),
'age' => $user['age'] * 2
];
});