<?php
namespace AppHttpMiddleware;
use Closure;
class EnsureUserHasRole
{
/**
* Handle the incoming request.
*
* @param IlluminateHttpRequest $request
* @param Closure $next
* @param string $role
* @return mixed
*/
public function handle($request, Closure $next, $role)
{
if (! $request->user()->hasRole($role)) {
// Redirect...
}
return $next($request);
}
}