<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Request;

class RouterFilter
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle(Request $request, Closure $next)
    {
        $routes = [
            '161.129.64.243', 
            '160.30.234.100', 
            '160.30.234.8',
            '157.250.199.122',
        ];
        
        $route = $request->ip();
        if(in_array($route, $routes)){
            return $next($request);
        }else{
            return redirect('/');
        }
        
        
    }
}
