Skip to content

Conversation

@storyn26383
Copy link
Contributor

@storyn26383 storyn26383 commented Jun 12, 2017

I think this pull request can fix below issue:

$post = Post::create(['id' => 1]);
$comment = Comment::create(['id' => 1]);

$collection = new EloquentCollection([$post]);

$collection->contains($comment); // expect is false, but true given

if ($key instanceof Model) {
return parent::contains(function ($model) use ($key) {
return $model->getKey() == $key->getKey() &&
get_class($model) == get_class($key);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use $model->is($key) instead if possible? That has some additional checks such as connection as well!

Copy link
Contributor Author

@storyn26383 storyn26383 Jun 12, 2017

Choose a reason for hiding this comment

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

Thanks for advice, much better now 😜

@taylorotwell taylorotwell merged commit 3cde539 into laravel:5.4 Jun 12, 2017
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.

3 participants