I have a question that appears to be simple.
I will quickly explain the practical problem:
- A radio has many coordinates.
- I have a collection of radios.
- I want to filter the coordinates based on a condition.
-
The below code doesn't work for some reason.
$radios = $radios->map(function ($item, $key) { $coordinates = $radio->coordinates; $coordinates = $coordinates->filter(function($coordinate, $key) { // return true or false; }); $radio['coordinates'] = $coordinates; return $radio; });
I can filter the coordinates collection but can't "attach" the filtered array to the radio object.
What am I doing wrong?
via Jacob Nørgaard