30 lines
623 B
PHP
30 lines
623 B
PHP
<?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');
|
|
|
|
if (Auth::user()->is_compras) {
|
|
return $next($request);
|
|
} else {
|
|
return response('Necesitás ser de comisión compras para hacer esto', 403);
|
|
}
|
|
}
|
|
}
|