LinkStack/app/Http/Middleware/admin.php
2021-04-16 03:30:00 +04:30

29 lines
505 B
PHP
Executable File

<?php
namespace App\Http\Middleware;
use Auth;
use Closure;
use Illuminate\Http\Request;
class admin
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle(Request $request, Closure $next)
{
//check is admin
if (Auth::user() && Auth::user()->role == 'admin') {
return $next($request);
}
return redirect('/');
}
}