예제 #1
0
 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);
 }
예제 #2
0
 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;
 }
예제 #3
0
 protected function onGet(\Controllers\Request $input)
 {
     $this->data['soil_types'] = Soil::all();
     return parent::onGet($input);
 }