Página 1

Hola a todos!

'; })->name('miprimerhtml'); //Segunda versión usando views // Si es invokable Route::get('/html/{nombre}', SaludoController::class); Route::get('/buscador', [BuscadorController::class, 'mostrarBuscador']); Route::post('/buscador', [BuscadorController::class, 'procesarFormulario']); Route::get('/ejer1', function(){ return DB::table('artists')->get(); }); Route::get('/ejer6', function(Request $request){ return DB::table('customers')->where('CustomerId', $request->input('id'))->firstOrFail(); }); Route::get('/ejer7', function(Request $request){ return DB::table('albums') ->join('artists', 'albums.ArtistId', '=', 'artists.ArtistId') ->get(); }); Route::get('/listado/{artista}', function(Artista $artista){ $artista = Artista::find(2); $albumCreado = $artista->albumes()->create([ 'Title' => "El nuevo album" ]); }); Route::get('/ejer9', function(){ $artistas = DB::table('artists') ->leftJoin('albums', 'artists.ArtistId', '=', 'albums.ArtistId') ->whereNull('albums.AlbumId') ->select('artists.*') ->get(); return $artistas; }); Route::get('/listado/{artista}/editar', function(Request $request, Artista $artista){ $artista->name = $request->input('nombre'); $artista->save(); return "Modelo actualizado"; }); Route::get('/listado/{artista}/eliminar', function(Request $request, Artista $artista){ $artista->delete(); return "Modelo eliminado"; }); Route::get('/listadoPlaylist', function(){ $track = Track::find(4); return $track->playlists; }); Route::get('/asociar', function(){ $track = Track::find(4); $playlist = Playlist::find(18); return $track->playlists()->attach($playlist); }); Route::get('/componentes', function(){ return view('componentes'); });