/** * new-Action (Formularauswertung) */ public function postNew() { $validator = Validator::make(Request::all(), Event::$rules); // validation has passed, write events in range on that date to xml File $geocoding_arr = Event::lookup(Request::input('adress')); $date = strtotime(Request::input('date')); (double) ($lat = $geocoding_arr['latitude']); (double) ($lng = $geocoding_arr['longitude']); //Start XML file, create parent node $xml = new XMLWriter(); $xml->openMemory(); $xml->startDocument('1.0', 'UTF-8'); if ($validator->passes()) { // validation has passed, save event in DB $event = new Event(); $event->title = Request::input('name'); $event->content = Request::input('content'); $event->link = Request::input('link'); $event->type = Request::input('type'); $event->latitude = $lat; $event->longitude = $lng; $event->save(); return redirect('events')->with('message', 'success|Event erfolgreich angelegt!'); } else { // validation has failed, display error messages return redirect('events/new')->with('message', 'danger|Die folgenden Fehler sind aufgetreten:')->withErrors($validator)->withInput(); } }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update($id) { $geocoding_arr = Event::lookup(Request::input('adress')); $date = strtotime(Request::input('date')); (double) ($lat = $geocoding_arr['latitude']); (double) ($lng = $geocoding_arr['longitude']); // $event = new Event(); $event->title = Request::input('title'); $event->content = Request::input('content'); $event->link = Request::input('link'); $event->type = Request::input('type'); $event->latitude = $lat; $event->longitude = $lng; $event->save(); $response = new \stdClass(); $response->success = true; $response->total = 1; $response->data = $event; return response()->json($response); }