3

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 :)

D.R.
  • 2,540
  • 3
  • 24
  • 49
  • You can extend the collection in laravel if you want to make it this way. Other way the unset is fastest – Bartłomiej Sobieszek Oct 11 '17 at 11:40
  • @BartłomiejSobieszek Thank you for the answer. Yes, I know about Collections macroses, but I though, that there could be a more obvious solution. I like neat and small pipelines. – D.R. Oct 11 '17 at 11:42

0 Answers0