whereVersion($version) ->firstOrFail(); abort_if($modVersion->mod->slug !== $slug, 404); $this->authorize('view', $modVersion); // Rate limit the downloads. $rateKey = 'mod-download:'.($request->user()?->id ?: $request->ip()); abort_if(RateLimiter::tooManyAttempts($rateKey, maxAttempts: 5), 429); // Increment downloads counts in the background. defer(fn () => $modVersion->incrementDownloads()); // Increment the rate limiter. RateLimiter::increment($rateKey); // Redirect to the download link, using a 307 status code to prevent browsers from caching. return redirect($modVersion->link, 307); } }