I
I
Ivan2021-03-10 16:03:24
Laravel
Ivan, 2021-03-10 16:03:24

Whether it is possible to check up that in a collection of objects there is a necessary property, at least in one object?

Good afternoon. The situation is something like this. There is a collection of objects of users. There can be one user, maybe several. How to check the collection, does at least one user have the property I need? If at least one has it, it will return true, if no one has it, it will return false.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
jazzus, 2021-03-10
@Djonson86

$users->contains('id', 1);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question