Skip to content

Latest commit

 

History

History
26 lines (22 loc) · 584 Bytes

middleware-conditional.md

File metadata and controls

26 lines (22 loc) · 584 Bytes

Notice: This example needs further troubleshooting for the newest verson 6.x. Use with caution.

<?php
namespace App\Http\Middleware;

use Closure;

class ConditionalMiddlware
{
    /**
     * Handle an incoming request.
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        if(app()->environment('staging', 'production')){
            app('router')->pushMiddlewareToGroup('web','throttle:75,1');
        }
        return $next($request);
    }
}