/** * Get the proper failed validation response for the request. * * @param array $errors * @return \Symfony\Component\HttpFoundation\Response */ public function response(array $errors) { if ($this->ajax() || $this->wantsJson()) { return new JsonResponse($errors, 422); } $properties = $this->mergeProperties(); $geometriedSelect = ['geometried_select' => Geometry::getGeometriedSelect($this->get('geometried_id'), $this->get('geometried_type'))]; $input = array_merge($this->except(array_merge($this->dontFlash, ['property_keys', 'property_names'])), $properties, $geometriedSelect); return $this->redirector->to($this->getRedirectUrl())->withInput($input)->withErrors($errors, $this->errorBag); }
/** * Run the database seeds. * * @return void */ public function run() { // DB::table('geometries')->delete(); // $data = 'data/regions/au.points.geojson'; // $data = 'data/regions/au.polygons.geojson'; $data = 'data/regions/001.points.geojson'; $geometries = json_decode(file_get_contents(base_path($data)), true); $features = GeoJson\GeoJson::jsonUnserialize($geometries); foreach ($features->getFeatures() as $feature) { $geometry = Geometry::createFromFeature($feature); } }
/** * Run the database seeds. * * @return void */ public function run() { $geometries = Geometry::where('geometried_id', null)->get(); foreach ($geometries as $geometry) { $name = $geometry->name; if (stripos($name, ' - ') !== false) { $name = last(explode(' - ', $name)); } if ($regions = Region::whereTranslation('name', $name)->where('shortcut_id', null)->where('is_structural', false)->whereIn('country_id', [15, 163])->get()) { if (count($regions) == 1) { $region = $regions->first(); $geometry->geometried()->associate($region); $geometry->save(); $this->command->line('<info>Associated</info> ' . $geometry->name . ' <info>to</info> ' . $region->name); } elseif (count($regions) == 0) { } else { $this->command->line('<info>Cannot Associate</info> ' . $geometry->name . ' <info>to</info> ' . count($regions) . ' regions'); } } } }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $geometry = Geometry::findOrFail($id); $this->authorize('destroy', $geometry); if ($geometry->delete()) { return redirect(action('GeometriesController@index'))->with('success', trans('messages.deleted_success')); } return redirect(action('GeometriesController@edit', $geometry->id))->with('error', trans('messages.deleted_error')); }