Skip to content

Conversation

@axlon
Copy link
Contributor

@axlon axlon commented Oct 26, 2018

This small PR makes the collection convenience method firstWhere work the same way as the where function does by making the second parameter optional.

Image we have a Post model with a boolean property published, if we wanted to retrieve the first published post we could do this

$collection->where('published')->first()

But if we use the convenience method firstWhere

# We have to pass true here, because the second argument is required
$collection->firstWhere('published', true)

With this PR the second argument to firstWhere is no longer required and boolean checks can be performed the same way as with the where function.

This PR is the same as #26260, but targets and branches from the correct branch.

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