예제 #1
0
 public function guardarNoticia()
 {
     $response = 0;
     $id_noticia = Noticia::codigo_nuevo_noticia();
     $titulo_noticia = e(Input::get('titulo_noticia'));
     $contenido_noticia = e(Input::get('contenido_noticia'));
     $enlace_noticia = e(Input::get('enlace_noticia'));
     $area_gestion_notica = e(Input::get('area_gestion_notica'));
     $imagen_noticia = Input::file('imagen_noticia');
     $centro = e(Input::get('centro_linea_investigacion'));
     $imagen_noticia_nombre = $id_noticia . '_imagenNoticia.' . $imagen_noticia->getClientOriginalExtension();
     $response = Centro::buscar_centro($centro);
     if (count($response) == 1) {
         $response = 0;
         $response = AreaGestion::buscar_area_gestion($area_gestion_notica);
         if (count($response) == 1) {
             $response = 0;
             $response = Noticia::insertar_noticia($id_noticia, $titulo_noticia, $contenido_noticia, $enlace_noticia, $area_gestion_notica, $imagen_noticia_nombre);
             if ($response == 1) {
                 $imagen_noticia->move('img/noticia', $imagen_noticia_nombre);
                 return Redirect::to(URL::previous())->with('mensaje', 'Noticia Insertada Correctamente');
             } else {
                 return Redirect::to(URL::previous())->with('mensaje', 'Ha ocurrido un error');
             }
         } else {
             return Redirect::to(URL::previous())->with('mensaje', 'No ha Seleccionado una Área de Gestión Válida');
         }
     } else {
         return Redirect::to(URL::previous())->with('mensaje', 'No ha Seleccionado un Centro de Investigación Válido');
     }
 }