52 lines
1.4 KiB
PHP
52 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Livewire\Admin;
|
|
|
|
use App\Models\FailedCheckout;
|
|
use LivewireUI\Modal\ModalComponent;
|
|
|
|
/**
|
|
* Einen geplatzten Kauf abhaken — im Modal, nicht in der Zeile (R20).
|
|
*
|
|
* Die erste Fassung hatte das Feld und den Knopf in der Liste stehen. Beides
|
|
* steht wörtlich in R20 unter „Verboten"; durchgerutscht ist es, weil der
|
|
* Wächtertest auf `<td>` prüft und die Zeilen `<li>` waren.
|
|
*
|
|
* Mutiert nichts selbst (R23): der Bestätigen-Knopf löst ein Ereignis aus, das
|
|
* Admin\PaymentProblems auffängt — damit bleibt die Berechtigungsprüfung an der
|
|
* einen Stelle, an der sie schon stand, statt hier verdoppelt zu werden. Der
|
|
* Aufruf hier prüft trotzdem: ein Modal ist ohne die Route-Middleware der Seite
|
|
* erreichbar.
|
|
*/
|
|
class ResolveFailedCheckout extends ModalComponent
|
|
{
|
|
public int $id;
|
|
|
|
public string $note = '';
|
|
|
|
public string $label = '';
|
|
|
|
public function mount(int $id): void
|
|
{
|
|
$this->authorize('billing.manage');
|
|
|
|
$problem = FailedCheckout::query()->findOr($id, fn () => abort(404));
|
|
|
|
$this->id = $problem->id;
|
|
$this->label = $problem->name ?: $problem->email;
|
|
}
|
|
|
|
public function confirm(): void
|
|
{
|
|
$this->authorize('billing.manage');
|
|
|
|
$this->dispatch('failed-checkout-resolved', id: $this->id, note: $this->note);
|
|
$this->closeModal();
|
|
}
|
|
|
|
public function render()
|
|
{
|
|
return view('livewire.admin.resolve-failed-checkout');
|
|
}
|
|
}
|