/** * Show the form for editing the specified social. * * @param int $id * @return Response */ public function edit($id) { $social = Social::find($id); return View::make('socials.edit', compact('social')); }
/** * * @param $action string * @param $id int * @return nothing * @author Tremor */ public function socialAction($action, $id = 0) { if (isset($id) && !empty($id) && !is_numeric($id)) { return Redirect::to('admin/social'); } switch ($action) { case 'add': $social = new Social(); $social->save(); $newId = $social->id; return Redirect::to('admin/social/' . $newId); break; case 'edit': $post = Input::except('_token'); // $affectedRows = Category::where('id', $categoryId)->update($post); $social = Social::find($id); foreach ($post as $key => $val) { if (isset($social->{$key})) { $social->{$key} = $val; } } $social->save(); return Redirect::to('admin/social/' . $id); break; case 'delete': $social = Social::find($id); $social->delete(); break; default: break; } return Redirect::to('admin/social'); }