Laravel Collections

$users = App\User::where('active', 1)->get();

foreach ($users as $user) {
    echo $user->name;
}
$users = App\User::all();

$names = $users->reject(function ($user) {
    return $user->active === false;
})
->map(function ($user) {
    return $user->name;
});

Available Methods

Related concepts

Laravel Collections — Structure map

Clickable & Draggable!

Laravel Collections — Related pages: