Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

laravel maintenance mode custom class

<?php namespace AppHttpMiddleware;

use Closure;
use IlluminateContractsFoundationApplication;
use IlluminateHttpRequest;
use IlluminateFoundationHttpMiddlewareCheckForMaintenanceMode as MaintenanceMode;

class CheckForMaintenanceMode {

    protected $app;

    public function __construct(Application $app)
    {
        $this->app = $app;
    }

    public function handle(Request $request, Closure $next)
    {
        if ($this->app->isDownForMaintenance() && 
            !in_array($request->getClientIp(), ['8.8.8.8', '8.8.4.4']))
        {
            $maintenanceMode = new MaintenanceMode($this->app);
            return $maintenanceMode->handle($request, $next);
        }

        return $next($request);
    }

}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #laravel #maintenance #mode #custom #class
ADD COMMENT
Topic
Name
3+9 =