/** * Updates all existing places with changes provided. * * @return view placeManagementView */ public function updatePlaces() { $places = Place::orderBy('plc_title', 'ASC')->get(); foreach ($places as $place) { if (Input::get('destroy' . $place->id)) { // find all schedules that use this place and replace it with a placeholder $filter = ClubEvent::where('plc_id', '=', $place->id)->get(); foreach ($filter as $event) { $event->plc_id = 0; // placeholder with plc_title "-" $event->save(); } Place::destroy($place->id); } else { // update title $place->plc_title = Input::get('plc_title' . $place->id); $place->save(); } } // need to update our index after the changes $places = Place::orderBy('plc_title', 'ASC')->get(); return View::make('placeManagementView', compact('places')); }
/** * Remove the specified place from storage. * * @param int $id * @return Response */ public function destroy($id) { Place::destroy($id); return Redirect::route('places.index'); }