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:
parent
05d8b5c8ef
commit
1522852c2c
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue