예제 #1
0
 public function update(PlaceUpdateRequest $request, $id)
 {
     $place = Place::findOrFail($id);
     foreach (array_keys(array_except($this->updateFields, ['article'])) as $field) {
         $place->{$field} = $request->get($field);
     }
     $changed = $place->isDirty() ? $place->getDirty() : false;
     if (!$changed) {
         return redirect("/admin/place/{$id}/edit")->withSuccess("No change was taken.");
     }
     if (!isset($changed['address'])) {
         if ($place->name) {
             $place->status = Place::IDENTIFIED;
         }
         $place->save();
         return redirect("/admin/place/{$id}/edit")->withSuccess("Changes saved.");
     }
     try {
         $place->identify();
         $place->save();
     } catch (\Exception $e) {
         return redirect("/admin/place/{$id}/edit")->withErrors($e->getMessage());
     }
     return redirect("/admin/place/{$id}/edit")->withSuccess("Changes saved.");
 }
예제 #2
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $place = Place::findOrFail($id);
     $place->delete();
     return redirect("places");
 }