File: /home/xedaptot/ai.naniguide.com/app/Notifications/Admin/InvoiceClaimedPaid.php
<?php
namespace App\Notifications\Admin;
use App\Model\Invoice;
use App\Notifications\AppNotification;
use Illuminate\Database\Eloquent\Model;
/**
* Customer claimed they paid an offline invoice — admins must review and
* approve / reject. Shared with all admins (audience='admins') so any admin
* can handle it; first to act records read_by_*; on approve / reject the
* group is cleared and the row dismissed.
*
* CTA links to the admin subscription list filtered by attention=pending_approval
* (the same surface admins use to triage pending claims). Route name is stored,
* not URL — the row stays valid across URL prefix changes.
*/
class InvoiceClaimedPaid extends AppNotification
{
public function __construct(public Invoice $invoice) {}
public function audience(): string { return self::AUDIENCE_ADMINS; }
public function category(): string { return self::CATEGORY_ACTION; }
public function severity(): string { return self::SEVERITY_WARNING; }
/** One row per invoice — repeated claims on the same invoice collapse. */
public function groupKey(): string
{
return 'invoice-claim:' . $this->invoice->id;
}
public function subject(): ?Model
{
return $this->invoice;
}
public function toArray(object $notifiable = null): array
{
$invoice = $this->invoice;
$customer = $invoice->customer;
return [
'title' => 'Offline payment claimed',
'body' => sprintf(
'Invoice %s from %s — claimed paid. Review and approve or reject.',
$invoice->number ?? ('#' . $invoice->id),
$customer?->displayName() ?? $customer?->name ?? 'a customer'
),
'action' => [
'label' => 'Review claim',
'route' => 'refactor.admin.subscriptions.index',
'params' => ['attention' => 'pending_approval'],
],
];
}
}