Skip to content

Instantly share code, notes, and snippets.

@geraldarcega
Created November 2, 2017 15:26
Show Gist options
  • Save geraldarcega/221fc307cf3607584e916eb150dc3839 to your computer and use it in GitHub Desktop.
Save geraldarcega/221fc307cf3607584e916eb150dc3839 to your computer and use it in GitHub Desktop.
IsAdmin middleware
<?php
namespace App\Http\Middleware;
use Closure;
class IsAdmin
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (\Auth::user() && \Auth::user()->type == 1) {
return $next($request);
}
return redirect('/');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment