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); } } }