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] Add a firstWhere method to the Collection class #22261

Merged
merged 1 commit into from
Nov 30, 2017

Conversation

JosephSilber
Copy link
Member

$firstActiveUser = $users->firstWhere('active', true);

@@ -45,6 +45,19 @@ public function testFirstWithDefaultAndWithoutCallback()
$this->assertEquals('default', $result);
}

public function testFirstWehre()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo in function name 😛

@taylorotwell taylorotwell merged commit ef7d16d into laravel:5.5 Nov 30, 2017
@taylorotwell
Copy link
Member

Just needed this yesterday 😄

@jordyvandomselaar
Copy link

Where's firstOrFailWhere?

@JosephSilber
Copy link
Member Author

@jordyvandomselaar right here:

$value = $c->firstWhere(...) ?? throw new Exception(...);

@jordyvandomselaar
Copy link

No no no, if we're adding methods for the heck of it that provide no value anyways we're gonna need this.

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.

4 participants