Eliminados middlewares no usados + reorden
This commit is contained in:
parent
1e7afc034e
commit
6bcb22ea00
3 changed files with 35 additions and 84 deletions
|
@ -1,20 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Middleware;
|
|
||||||
|
|
||||||
use Closure;
|
|
||||||
use Illuminate\Support\Facades\Auth;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
|
|
||||||
class Admin
|
|
||||||
{
|
|
||||||
public function handle(Request $request, Closure $next)
|
|
||||||
{
|
|
||||||
$user = Auth::user();
|
|
||||||
if ($user->is_admin) {
|
|
||||||
return $next($request);
|
|
||||||
} else {
|
|
||||||
return response('Necesitás ser admin para hacer esto', 403);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,29 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Middleware;
|
|
||||||
|
|
||||||
use Closure;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Illuminate\Support\Facades\Auth;
|
|
||||||
|
|
||||||
class Compras
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Handle an incoming request.
|
|
||||||
*
|
|
||||||
* @param Request $request
|
|
||||||
* @param Closure $next
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function handle(Request $request, Closure $next)
|
|
||||||
{
|
|
||||||
if (!Auth::check())
|
|
||||||
return redirect()->route('compras_login.show');
|
|
||||||
|
|
||||||
if (Auth::user()->is_compras) {
|
|
||||||
return $next($request);
|
|
||||||
} else {
|
|
||||||
return response('Necesitás ser de comisión compras para hacer esto', 403);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -20,9 +20,43 @@ if (App::environment('production')) {
|
||||||
URL::forceScheme('https');
|
URL::forceScheme('https');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Auth::routes(['register' => false]);
|
||||||
|
|
||||||
Route::get('/', 'RouteController@home')->name('home');
|
Route::get('/', 'RouteController@home')->name('home');
|
||||||
|
|
||||||
Auth::routes(['register' => false]);
|
Route::middleware(['auth', 'role:barrio'])->group( function() {
|
||||||
|
Route::get('/productos', 'ProductoController@index')->name('productos.index');
|
||||||
|
|
||||||
|
Route::name('subpedidos.')->prefix("subpedidos")->group( function() {
|
||||||
|
Route::get('/', function() {
|
||||||
|
return view('subpedidos_create');
|
||||||
|
})->name('create');
|
||||||
|
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
if (!isset($r["grupo_de_compra_id"])) {
|
||||||
|
throw new HttpException(400, "La request necesita un grupo de compra para guardar en sesión");
|
||||||
|
}
|
||||||
|
session(["subpedido_nombre" => $r["subpedido"]["nombre"]]);
|
||||||
|
session(["subpedido_id" => $r["subpedido"]["id"]]);
|
||||||
|
session(["gdc" => $r["grupo_de_compra_id"]]);
|
||||||
|
return "Subpedido guardado en sesión";
|
||||||
|
})->name('guardarSesion');
|
||||||
|
|
||||||
|
Route::get('obtener_sesion', function() {
|
||||||
|
return [
|
||||||
|
'subpedido' => [
|
||||||
|
'nombre' => session("subpedido_nombre"),
|
||||||
|
'id' => session("subpedido_id")
|
||||||
|
],
|
||||||
|
'gdc' => session("gdc")
|
||||||
|
];
|
||||||
|
})->name('obtenerSesion');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
Route::get('/admin/login', 'AdminController@show')->name('admin.login');
|
Route::get('/admin/login', 'AdminController@show')->name('admin.login');
|
||||||
|
|
||||||
|
@ -42,40 +76,6 @@ Route::middleware(['auth', 'role:admin_barrio'])->group( function () {
|
||||||
Route::get('/admin/exportar-pedido-con-nucleos-a-csv/{gdc}', 'AdminController@exportarPedidoConNucleosACSV');
|
Route::get('/admin/exportar-pedido-con-nucleos-a-csv/{gdc}', 'AdminController@exportarPedidoConNucleosACSV');
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::middleware(['auth', 'role:barrio'])->group( function() {
|
|
||||||
Route::get('/productos', 'ProductoController@index')->name('productos.index');
|
|
||||||
|
|
||||||
Route::name('subpedidos.')->prefix("subpedidos")->group( function() {
|
|
||||||
Route::get('/', function() {
|
|
||||||
return view('subpedidos_create');
|
|
||||||
})->name('create');
|
|
||||||
|
|
||||||
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");
|
|
||||||
}
|
|
||||||
if (!isset($r["grupo_de_compra_id"])) {
|
|
||||||
throw new HttpException(400, "La request necesita un grupo de compra para guardar en sesión");
|
|
||||||
}
|
|
||||||
session(["subpedido_nombre" => $r["subpedido"]["nombre"]]);
|
|
||||||
session(["subpedido_id" => $r["subpedido"]["id"]]);
|
|
||||||
session(["gdc" => $r["grupo_de_compra_id"]]);
|
|
||||||
return "Subpedido guardado en sesión";
|
|
||||||
})->name('guardarSesion');
|
|
||||||
|
|
||||||
Route::get('obtener_sesion', function() {
|
|
||||||
return [
|
|
||||||
'subpedido' => [
|
|
||||||
'nombre' => session("subpedido_nombre"),
|
|
||||||
'id' => session("subpedido_id")
|
|
||||||
],
|
|
||||||
'gdc' => session("gdc")
|
|
||||||
];
|
|
||||||
})->name('obtenerSesion');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
Route::get('/compras/login', 'ComprasController@show')->name('compras.login');
|
Route::get('/compras/login', 'ComprasController@show')->name('compras.login');
|
||||||
|
|
||||||
Route::middleware(['auth', 'role:comision'])->group( function() {
|
Route::middleware(['auth', 'role:comision'])->group( function() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue