weeb 5a463656a7
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (push) Has been cancelled
Display applications in admin interface
2025-05-01 23:07:38 +02:00

45 lines
946 B
PHP

<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Contracts\Auth\Guard;
use Symfony\Component\HttpFoundation\Response;
class IsAdmin
{
/**
* The Guard implementation.
*
* @var Guard
*/
protected $auth;
/**
* Create a new filter instance.
*
* @param Guard $auth
* @return void
*/
public function __construct(Guard $auth)
{
$this->auth = $auth;
}
/**
* Handle an incoming request.
*
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
*/
public function handle(Request $request, Closure $next): Response
{
if (!$this->auth->user()->is_admin) {
session()->flash('error_msg', 'This resource is restricted to Administrators!');
return redirect()->route('home');
}
return $next($request);
}
}