laravel maintenance mode custom class

Solutions on MaxInterview for laravel maintenance mode custom class by the best coders in the world

showing results for - "laravel maintenance mode custom class"
Dario
20 Mar 2017
1<?php namespace App\Http\Middleware;
2
3use Closure;
4use Illuminate\Contracts\Foundation\Application;
5use Illuminate\Http\Request;
6use Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode as MaintenanceMode;
7
8class CheckForMaintenanceMode {
9
10    protected $app;
11
12    public function __construct(Application $app)
13    {
14        $this->app = $app;
15    }
16
17    public function handle(Request $request, Closure $next)
18    {
19        if ($this->app->isDownForMaintenance() && 
20            !in_array($request->getClientIp(), ['8.8.8.8', '8.8.4.4']))
21        {
22            $maintenanceMode = new MaintenanceMode($this->app);
23            return $maintenanceMode->handle($request, $next);
24        }
25
26        return $next($request);
27    }
28
29}
30