File: /home/xedaptot/ai.naniguide.com/app/Notifications/Customer/RenewOrderCreated.php
<?php
namespace App\Notifications\Customer;
use App\Model\Order;
use App\Notifications\AppNotification;
use Illuminate\Database\Eloquent\Model;
/**
* A renewal Order has been auto-created for the customer's subscription
* (cron job, before period end). Surfaces in the customer bell so they
* can review/pay the invoice before auto-charge fires.
*/
class RenewOrderCreated extends AppNotification
{
public function __construct(public Order $order) {}
public function audience(): string { return self::AUDIENCE_DIRECT; }
public function category(): string { return self::CATEGORY_INFO; }
public function severity(): string { return self::SEVERITY_INFO; }
public function groupKey(): string
{
return 'renew-order:' . $this->order->id;
}
public function subject(): ?Model
{
return $this->order;
}
public function toArray(object $notifiable = null): array
{
$invoice = $this->order->getItsOnlyInvoice();
$sub = $this->order->orderItems->first()?->subscription;
return [
'title' => trans('refactor/notifications.renew_order_created.title'),
'body' => trans('refactor/notifications.renew_order_created.body', [
'plan' => $sub?->plan?->name ?? '—',
'amount' => $invoice?->formattedTotal() ?? '—',
'date' => optional($sub?->current_period_ends_at)->toDateString() ?? '—',
]),
];
}
}