Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.5] Pass test value to Collection::when callbacks #22224

Merged
merged 1 commit into from
Nov 27, 2017

Conversation

alepeino
Copy link
Contributor

This brings the method in line with Illuminate\Database\Concerns\BuildsQueries::when, and avoids the need for a use statement when we want the truthy value inside the callback.

For instance:

$item = $items->next();
$collection->when($item, function ($collection) use ($item) {
    return $collection->push($item);
});

can become

$collection->when($items->next(), function ($collection, $item) {
    return $collection->push($item);
});

@taylorotwell taylorotwell merged commit 3956865 into laravel:5.5 Nov 27, 2017
@GrahamCampbell GrahamCampbell changed the title Pass test value to Collection::when callbacks [5.5] Pass test value to Collection::when callbacks Nov 27, 2017
@alepeino alepeino deleted the collection-when-parameter branch November 28, 2017 03:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants