public function vistaListado()
 {
     $items_borrados = Item::where('estado', 'B')->lists('id');
     if (count($items_borrados) > 0) {
         $noticias = Texto::whereNotIn('item_id', $items_borrados)->get();
     } else {
         $noticias = Noticia::all();
     }
     $categorias = Categoria::where('estado', 'A')->get();
     $secciones = Seccion::where('estado', 'A')->get();
     $this->array_view['noticias'] = $noticias;
     $this->array_view['categorias'] = $categorias;
     $this->array_view['secciones'] = $secciones;
     //Hace que se muestre el html lista.blade.php de la carpeta item
     //con los parametros pasados por el array
     return View::make($this->folder_name . '.lista', $this->array_view);
 }
示例#2
0
        $noticia->fechaNoticia = date("Y-m-d H:i:s");
        $noticia->textoNoticia = $datos["txtContenido"];
        $aux = User::where("email", "=", Session::get("email"))->firstOrFail();
        $noticia->fkidUsuario = $aux->id;
        //$n->imagenUrl = "/img/hola.png";
        if ($noticia->save()) {
            $noticia->imagenUrl = 'imgsnoticias/' . $noticia->id . "." . $imagen->getClientOriginalExtension();
            //guardamos la imagen en public/imgs con el nombre original
            $imagen->move("imgsnoticias", $noticia->id . "." . $imagen->getClientOriginalExtension());
            $noticia->save();
            //redirigimos con un mensaje flash
            return Redirect::to('admin')->with(array('confirm' => 'Noticia publicada correctamente.'));
        } else {
            return Redirect::to('admin/noticias/add')->with(array('error' => 'Error. No se pudo publicar la noticia.'));
        }
    }
}));
Route::get("login", function () {
    if (Auth::check()) {
        return Redirect::to("admin");
    } else {
        return View::make("admin.login");
    }
});
Route::get("admin", function () {
    $noticias = Noticia::all();
    return View::make("admin.index")->with("noticias", $noticias);
});
Route::get("admin/noticias/add", function () {
    return View::make("admin.noticias.add");
});