vendredi 23 février 2018

Laravel: Filter collection on property, with a twist

I am looking for an elegant (and comprehensible in a year's time) solution for a collection filtering challenge. I am querying a log database and get some sort of the following data structure

| refId   | isDeleted   | loggedDate          |
|---------|-------------|---------------------|
| 1       | 0           | 2018-02-23 21:39:05 |
| 2       | 0           | 2018-02-23 21:39:05 |
| 3       | 0           | 2018-02-23 21:39:05 |
| 4       | 0           | 2018-02-23 21:39:05 |
| 2       | 1           | 2018-02-23 21:49:05 |
| 5       | 0           | 2018-02-23 21:49:05 |
| 6       | 1           | 2018-02-23 21:49:05 |

My objective is to filter out the entries which have both, isDeleted=0 && isDeleted=1, and to leave only those which are either isDeleted=0 or isDeleted=1. In this example I should end up with datasets of 1, 3, 4, 5 and 6.

Thx.

PS. The collection might hold up to 1000 entries, if you were to ask...



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2F3TJ36
via IFTTT

Aucun commentaire:

Enregistrer un commentaire