diff --git a/app/Http/Controllers/Mini/PaymentQrController.php b/app/Http/Controllers/Mini/PaymentQrController.php index db79985..b26e231 100644 --- a/app/Http/Controllers/Mini/PaymentQrController.php +++ b/app/Http/Controllers/Mini/PaymentQrController.php @@ -101,6 +101,17 @@ class PaymentQrController extends Controller return back()->with('success', 'Payment QR updated.'); } + public function destroy(QrCode $paymentQr): RedirectResponse + { + $this->authorizePaymentQr($paymentQr); + + $this->manager->delete($paymentQr); + + return redirect() + ->route('mini.payment-qrs.index') + ->with('success', 'Payment QR deleted.'); + } + public function preview(QrCode $paymentQr): Response { $this->authorizePaymentQr($paymentQr); diff --git a/app/Services/Qr/QrCodeManagerService.php b/app/Services/Qr/QrCodeManagerService.php index b76bdea..29f6df2 100644 --- a/app/Services/Qr/QrCodeManagerService.php +++ b/app/Services/Qr/QrCodeManagerService.php @@ -536,4 +536,20 @@ class QrCodeManagerService throw new RuntimeException('Could not generate a unique QR short code.'); } + + public function delete(QrCode $qrCode): void + { + $paths = array_filter([$qrCode->png_path, $qrCode->svg_path]); + + $logoPath = $qrCode->content()['logo_path'] ?? null; + if (is_string($logoPath) && $logoPath !== '') { + $paths[] = $logoPath; + } + + foreach ($paths as $path) { + Storage::disk('qr')->delete($path); + } + + $qrCode->delete(); + } } diff --git a/resources/views/mini/payment-qrs/index.blade.php b/resources/views/mini/payment-qrs/index.blade.php index a61e49c..d8a0021 100644 --- a/resources/views/mini/payment-qrs/index.blade.php +++ b/resources/views/mini/payment-qrs/index.blade.php @@ -8,6 +8,9 @@ New payment QR + @if(session('success')) +
No payment QRs yet.
diff --git a/resources/views/mini/payment-qrs/show.blade.php b/resources/views/mini/payment-qrs/show.blade.php index 63847f1..266bddc 100644 --- a/resources/views/mini/payment-qrs/show.blade.php +++ b/resources/views/mini/payment-qrs/show.blade.php @@ -40,6 +40,7 @@{{ $qrCode->publicUrl() }}
Removes this QR and its payment link. Scans will stop working. This cannot be undone.
+ +