From aa3732134168496c76064e7a135326dd44aeab06 Mon Sep 17 00:00:00 2001 From: Mohammad Azam Rahmanpour Date: Mon, 7 Oct 2024 10:45:34 +0330 Subject: [PATCH] add a functionality to reset FilePond instance (#21) --- resources/views/upload.blade.php | 4 ++++ src/WithFilePond.php | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/resources/views/upload.blade.php b/resources/views/upload.blade.php index 21db27e..ad9cdc6 100644 --- a/resources/views/upload.blade.php +++ b/resources/views/upload.blade.php @@ -89,6 +89,10 @@ class="{{ $attributes->get('class') }}" pond.on('addfile', (error, file) => { if (error) console.log(error); }); + + $wire.on('filepond-reset-{{ $wireModelAttribute }}', () => { + pond.removeFiles(); + }); }" > diff --git a/src/WithFilePond.php b/src/WithFilePond.php index dca2b06..d39e889 100644 --- a/src/WithFilePond.php +++ b/src/WithFilePond.php @@ -40,4 +40,10 @@ public function revert($property, $filename): void return false; }); } + + public function resetFilePond(string $property): void + { + $this->reset($property); + $this->dispatch("filepond-reset-$property"); + } }