pedi2/routes/web.php

56 lines
1.6 KiB
PHP
Raw Permalink Normal View History

2021-12-30 11:49:40 -03:00
<?php
use Illuminate\Support\Facades\Route;
2022-01-11 17:24:46 -03:00
use Symfony\Component\HttpKernel\Exception\HttpException;
2021-12-30 11:49:40 -03:00
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
if (App::environment('production')) {
URL::forceScheme('https');
}
2022-01-08 02:53:00 -03:00
Route::get('/', 'ProductoController@index')->name('productos');
Auth::routes(['register' => false]);
Route::get('/productos', 'ProductoController@index')->name('productos.index');
Route::get('/chismosa', 'ChismosaController@show')->name('chismosa.show');
2022-01-11 17:24:46 -03:00
Route::middleware('auth')->group( function() {
Route::name('subpedidos.')->prefix("subpedidos")->group( function() {
Route::get('/', function() {
return view('subpedidos_create');
})->name('create');
2022-01-11 17:24:46 -03:00
Route::post('guardar_sesion', function() {
$r = request();
if (!isset($r["subpedido"])) {
throw new HttpException(400, "La request necesita un subpedido para guardar en sesión");
}
session(["subpedido_nombre" => $r["subpedido"]["nombre"]]);
session(["subpedido_id" => $r["subpedido"]["id"]]);
return "Subpedido guardado en sesión";
})->name('guardarSesion');
Route::get('obtener_sesion', function() {
$sesion = [
'subpedido' => [
'nombre' => session("subpedido_nombre"),
'id' => session("subpedido_id")
]
];
return $sesion;
})->name('obtenerSesion');
2022-01-11 17:24:46 -03:00
});
});