2021-04-16 01:00:00 +02:00
|
|
|
<?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);
|
|
|
|
}
|
|
|
|
|
2023-07-17 16:52:43 +02:00
|
|
|
return redirect(url('dashboard'));
|
2021-04-16 01:00:00 +02:00
|
|
|
}
|
|
|
|
}
|