FleetCart/app/Http/Middleware/CheckForMaintenanceMode.php

47 lines
1.1 KiB
PHP
Raw Normal View History

2023-06-11 12:14:03 +00:00
<?php
namespace FleetCart\Http\Middleware;
use Closure;
2023-12-03 14:07:47 +00:00
use Illuminate\Http\Request;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Illuminate\Foundation\Http\Exceptions\MaintenanceModeException;
2023-06-11 12:14:03 +00:00
use Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode as BaseCheckForMaintenanceMode;
class CheckForMaintenanceMode extends BaseCheckForMaintenanceMode
{
/**
* The URIs that should be accessible while maintenance mode is enabled.
*
* @var array
*/
protected $except = [
'*/admin*',
];
2023-12-03 14:07:47 +00:00
2023-06-11 12:14:03 +00:00
/**
* Handle an incoming request.
*
2023-12-03 14:07:47 +00:00
* @param Request $request
* @param Closure $next
*
2023-06-11 12:14:03 +00:00
* @return mixed
*
2023-12-03 14:07:47 +00:00
* @throws HttpException
* @throws MaintenanceModeException
2023-06-11 12:14:03 +00:00
*/
2023-12-03 14:07:47 +00:00
public function handle($request, Closure $next): mixed
2023-06-11 12:14:03 +00:00
{
if (
config('app.installed')
&& $this->app->isDownForMaintenance()
&& optional(auth()->user())->hasRoleName('Admin')
) {
return $next($request);
}
return parent::handle($request, $next);
}
}