public function eliminarnoticia($id) { $noticia = Noticias::find($id); if ($noticia->user_id == Auth::user()->id || Auth::user()->admin == 1) { $noticia->delete(); Session::flash('message', 'Noticia Borrada Correctamente'); return Redirect::to("ver-noticias"); } else { flashMessage("No posee los permisos para realizar esta acción", 'red'); return Redirect::back(); } }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { if (Auth::user()->id == Noticias::find($id)->user_id || Auth::user()->admin == 1) { Noticias::destroy($id); return "true"; } else { return "false"; } }
public function noticias($action) { if (isset($action)) { if ($action == "create") { $data = Noticias::firstOrCreate(Input::all()); return $respuesta = array('Record' => $data, 'Result' => "OK"); } if ($action == "edit") { Noticias::where("id", Input::get("id"))->update(Input::except("id")); return $respuesta = array('Record' => Noticias::find(Input::get('id')), 'Result' => "OK"); } if ($action == "remove") { $path = Noticias::find(Input::get("id"))->media; Event::fire('eliminarArchivo', public_path() . "/images/" . $path); Noticias::where('id', Input::get("id"))->delete(); return '{"Result":"OK"}'; } if ($action == "list") { $Records = Noticias::get(); $respuesta = array('Records' => $Records, 'Result' => "OK"); return json_encode($respuesta); } } }
public function getDetalle($id = null) { $datos = Noticias::find($id); return $this->layout->content = View::make('test.detalle', compact("datos")); }