mercredi 11 octobre 2017

Laravel Collections. forget() on nested key

Is it possible to use some neat Laravel collection method similar to forget(), that will work with nested arrays.

Here is an example of what I want.

I have such a Collection instance:

enter image description here

And I want to drop coordinates column (all items are identical) in a similar way to

$cities->forget('cities', 2) // (second parameter is not real, it's a "nested level" and I took it from my head as example of what I want)

As an answer I'd like to receive some existing Collection method or a Collection macro, that will work in one line.

All other "more than one line options" with unset() and map() won't be better, than what I have now :)



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire