Laravel collection contains

Solution 1:

You should pass a key / value pair to the contains method, which will determine if the given pair exists in the collection.

You should use contains() method in this way:

foreach ($this->options as $option) {
  // Pass key inside contains method
  if($option->contains('id', $option->id)) {
      dd('test');
  }
}

Solution 2:

Use the following, which tells Laravel you want to match the 'id':

$options->contains('id', $option->id);

Docs