Skip to content

Commit

Permalink
add support for file request parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
larowka committed Jun 21, 2024
1 parent 8929e35 commit 5a0d0d5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ All notable changes to `prevent-duplicate-requests` will be documented in this f

## 1.0.0 - 2024-06-19

- Initial release
- Initial release

## 1.1.0 - 2024-06-21

- Added support for file request parameters
10 changes: 9 additions & 1 deletion src/Middleware/PreventDuplicateRequests.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Closure;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Http\Request;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Cache;
use Symfony\Component\HttpKernel\Exception\TooManyRequestsHttpException;

Expand Down Expand Up @@ -40,7 +41,14 @@ public function handle(Request $request, Closure $next, int $seconds = 5): mixed
*/
protected function getRequestKey(Request $request): string
{
$input = $request->all();
$input = $request->input();

if ($files = $request->allFiles()) {
foreach ($files as $key => $file) {
/** @var UploadedFile $file */
$input[$key] = $file->getClientOriginalName() . $file->getSize();
}
}

if (($auth = $request->user()) && $auth instanceof Authenticatable) {
$user = $auth->getAuthIdentifier();
Expand Down

0 comments on commit 5a0d0d5

Please sign in to comment.