fixing the code example for Eloquent collections

In the example, users were filtered twice - once in query builder and then in reject collection method.
This commit is contained in:
Amadeusz Annissimo 2017-12-17 07:44:21 -07:00 committed by GitHub
parent 05d8b5c8ef
commit 1522852c2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -19,7 +19,7 @@ Of course, all collections also serve as iterators, allowing you to loop over th
However, collections are much more powerful than arrays and expose a variety of map / reduce operations that may be chained using an intuitive interface. For example, let's remove all inactive models and gather the first name for each remaining user:
$users = App\User::where('active', 1)->get();
$users = App\User::all();
$names = $users->reject(function ($user) {
return $user->active === false;