Convert optional() to nullsafe operator

This commit is contained in:
Shift 2023-01-05 17:02:33 +00:00
parent df257ead7a
commit a9d76b1cfd
No known key found for this signature in database
GPG key ID: 5A96F038425C5A1C

View file

@ -57,10 +57,10 @@ class RouteServiceProvider extends ServiceProvider
protected function configureRateLimiting()
{
RateLimiter::for('api', function (Request $request) {
return Limit::perMinute(60)->by(optional($request->user())->id ?: $request->ip());
return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
});
RateLimiter::for('web', function (Request $request) {
return Limit::perMinute(40)->by(optional($request->user())->id ?: $request->ip());
return Limit::perMinute(40)->by($request->user()?->id ?: $request->ip());
});
}
}