-
Notifications
You must be signed in to change notification settings - Fork 0
2. Routes
carlos prato edited this page Nov 20, 2019
·
1 revision
-
Documentacion: https://laravel.com/docs/5.8/routing
-
definen las rutas URL de las peticiones (GET,POST) y se asocian con un controlador o con una view directamente.
-
cada route se le asigna un nombre, en el codigo se usara este nombre para apuntar a su URL
route('nombre-clave')
-
Responder solo texto:
Route::get('ruta1',function{ return "responder este Texto";})>name('nombre-clave');
-
Responder View:
Route::view('/about','about')->name('about')
-
Captar datos por la url y responder un View. Ej. localhost/subpagina/valor
-
Route::get('/ruta/{variable?}', function ($variable ='valor_predeterminado') { return view('nombre_view',['variable' -> $variable]); })->name('nombre-clave');
-
Responder View pasandole una constante:
Route::view('/ruta','subpagina',['variable' => 'CONSTANTE'])->name('nombre-clave');
-
Responder View pasandole un array:
-
<?php $array = [ ['title'=>'valor1'], ['title'=>'valor2'], ]; Route::view('/ruta','subpagina',compact('array'))->name('nombre-clave');