File tree Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Original file line number Diff line number Diff line change @@ -17,13 +17,12 @@ Quick port of the [Facebook's DataLoader](https://github.com/facebook/dataloader
1717$userByIdLoader = new DataLoader(function ($ids) {
1818 $users = User::findMany($ids);
1919
20- // Make sure that the users are on the same order as the given ids
20+ // Make sure that the users are on the same order as the given ids for the loader
2121 $orderedUsers = collect($ids)->map(function ($id) use ($users) {
22- foreach ($users as $user) {
23- if ($user->id === $id) {
24- return $user;
25- }
26- });
22+ return $users->first(function ($user) use ($id) {
23+ return $user->id === $id;
24+ });
25+ });
2726
2827 return \React\Promise\resolve($orderedUsers);
2928}, $eventLoopFromIoCContainer, $cacheMapFromIoCContainer);
You can’t perform that action at this time.
0 commit comments