protected function onPost(\Controllers\Request $input) { $id = $input->get('id'); $this->data['update_success'] = false; try { Soil::find($id)->delete(); $this->data['delete_success'] = true; $this->view = 'admin.soil.index'; $this->data['soil_types'] = Soil::all(); } catch (\Exceptions\Validation $ex) { $this->data['errors'] = $ex->validator->errors(); } catch (\Exception $ex) { $this->errors->add('delete-error', $ex->getMessage()); } return parent::onPost($input); }
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; }
protected function onGet(\Controllers\Request $input) { $this->data['soil_types'] = Soil::all(); return parent::onGet($input); }