private function _expandInput($input) { $result = ['modules' => [], 'soils' => []]; $soilById = Soil::byId(Soil::all()); $perimeters = array_get($input, 'soils', []); foreach ($perimeters as $poly) { $polygon = new Polygon($poly['p']); $soil = array_get($soilById, array_get($poly, 's', ''), new Soil()); $result['soils'][] = ['polygon' => $polygon, 'soil' => $soil]; } return $result; }