There are 2 things to take care of.
1) get a helper function that returns the Illuminate\Http\Request method and call ->ip() .
request()->ip();
2) Think about the configuration of your server, it can use a proxy or load balancer (especially in the AWS ELB configuration)
If this is your case, you need to configure trusted proxies, or perhaps even set the option Trusting All Proxies .
What for?
Because, as your server, you will receive your IP proxy / balancer.
How?
If you are not using AWS balance-loader
Go to App\Http\Middleware\TrustProxies
and make the $proxies declaration look like this:
protected $proxies = '*';
Now check it out and celebrate because you just got rid of throttle middleware issues. It also relies on request()->ip() and without setting TrustProxies you can TrustProxies all your users log in instead of only blocking the culprit's IP address.
And since throttle middleware not described properly in the documentation, I recommend watching this video
Tested in Laravel 5.7
Yevgeniy Afanasyev Dec 18 '18 at 22:48 2018-12-18 22:48
source share