Add delete for Mini payment QRs.
Deploy Ladill Mini / deploy (push) Successful in 33s

Vendors can remove a payment QR from the show page; stored images are cleaned up and the short link stops resolving.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
isaacclad
2026-06-07 20:49:15 +00:00
co-authored by Cursor
parent 327cf65e6c
commit f52e3e882e
5 changed files with 44 additions and 0 deletions
@@ -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);
+16
View File
@@ -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();
}
}
@@ -8,6 +8,9 @@
</div>
<a href="{{ route('mini.payment-qrs.create') }}" class="inline-flex rounded-xl bg-indigo-600 px-4 py-2 text-sm font-semibold text-white hover:bg-indigo-700">New payment QR</a>
</div>
@if(session('success'))
<div class="rounded-xl border border-emerald-100 bg-emerald-50 px-4 py-3 text-sm text-emerald-800">{{ session('success') }}</div>
@endif
@if($qrCodes->isEmpty())
<div class="rounded-2xl border border-dashed border-slate-200 bg-white px-6 py-12 text-center">
<p class="text-sm text-slate-500">No payment QRs yet.</p>
@@ -40,6 +40,7 @@
<p class="mt-4 break-all text-center text-sm text-indigo-600">{{ $qrCode->publicUrl() }}</p>
</div>
<div class="space-y-4">
<form method="post" action="{{ route('mini.payment-qrs.update', $qrCode) }}" class="space-y-4 rounded-2xl border border-slate-200 bg-white p-6">
@csrf
@method('PATCH')
@@ -62,6 +63,18 @@
</label>
<button type="submit" class="rounded-xl bg-indigo-600 px-4 py-2 text-sm font-semibold text-white hover:bg-indigo-700">Save changes</button>
</form>
<div class="rounded-2xl border border-red-100 bg-white p-6">
<h2 class="font-semibold text-red-700">Delete payment QR</h2>
<p class="mt-1 text-sm text-slate-500">Removes this QR and its payment link. Scans will stop working. This cannot be undone.</p>
<form method="post" action="{{ route('mini.payment-qrs.destroy', $qrCode) }}" class="mt-4"
onsubmit="return confirm('Delete {{ $qrCode->label }}? The payment link will stop working.')">
@csrf
@method('DELETE')
<button type="submit" class="rounded-xl bg-red-600 px-4 py-2 text-sm font-semibold text-white hover:bg-red-700">Delete payment QR</button>
</form>
</div>
</div>
</div>
</div>
</x-user-layout>
+1
View File
@@ -43,6 +43,7 @@ Route::middleware(['auth'])->group(function () {
Route::post('/payment-qrs', [PaymentQrController::class, 'store'])->name('mini.payment-qrs.store');
Route::get('/payment-qrs/{paymentQr}', [PaymentQrController::class, 'show'])->name('mini.payment-qrs.show');
Route::patch('/payment-qrs/{paymentQr}', [PaymentQrController::class, 'update'])->name('mini.payment-qrs.update');
Route::delete('/payment-qrs/{paymentQr}', [PaymentQrController::class, 'destroy'])->name('mini.payment-qrs.destroy');
Route::get('/payment-qrs/{paymentQr}/preview.png', [PaymentQrController::class, 'preview'])->name('mini.payment-qrs.preview');
Route::get('/payment-qrs/{paymentQr}/download/{format}', [PaymentQrController::class, 'download'])->name('mini.payment-qrs.download')->whereIn('format', ['png', 'svg', 'pdf']);