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:
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user