1

I have this collection:

Collection {#604 ▼
  #items: array:4 [▼
    0 => CarsMark {#596 ▶}
    1 => CarsMark {#594 ▶}
    2 => CarsMark {#594 ▶}
    3 => CarsMark {#595 ▶}
  ]
}

As you can see there is two the same items (594). How can i retrieve all items from with collection without the same items?

1
  • Are you looking to include only one instance of 594 in the final results or have both 594's removed? Commented Sep 3, 2015 at 20:08

1 Answer 1

2

Use the collection's unique method:

$unique = $collection->unique();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.