misc_pterodactyl-panel/app/Http/Middleware/MaintenanceMiddleware.php
2018-05-26 11:00:28 -07:00

44 lines
1,019 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.
*
* @param \Illuminate\Contracts\Routing\ResponseFactory $response
*/
public function __construct(ResponseFactory $response)
{
$this->response = $response;
}
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @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) {
return $this->response->view('errors.maintenance');
}
return $next($request);
}
}