Файл: app/Http/Middleware/AdminMiddleware.php
Строк: 24
<?php
namespace AppHttpMiddleware;
use Closure;
use IlluminateContractsAuthGuard;
class AdminMiddleware
{
/**
* @var
*/
protected $auth;
public function __construct(Guard $auth)
{
$this->auth = $auth;
}
/**
* Handle an incoming request.
*
* @param IlluminateHttpRequest $request
* @param Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
// If the user is a guest, or doesn't have permissions
if ($this->auth->guest() || $this->auth->user()->role != 1) {
return redirect()->route('home');
}
return $next($request);
}
}