misc_pterodactyl-panel/app/Http/Middleware/MaintenanceMiddleware.php
2021-01-23 12:33:34 -08:00

42 lines
909 B
PHP

<?php
namespace Pterodactyl\Http\Middleware;
use Closure;
use Illuminate\Contracts\Routing\ResponseFactory;
class MaintenanceMiddleware
{
/**
* @var \Illuminate\Contracts\Routing\ResponseFactory
*/
private $response;
/**
* MaintenanceMiddleware constructor.
*/
public function __construct(ResponseFactory $response)
{
$this->response = $response;
}
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
*
* @return mixed
*/
public function handle($request, Closure $next)
{
/** @var \Pterodactyl\Models\Server $server */
$server = $request->attributes->get('server');
$node = $server->getRelation('node');
if ($node->maintenance_mode) {
return $this->response->view('errors.maintenance');
}
return $next($request);
}
}