Deploy Ladill Woo Manager / deploy (push) Successful in 2m11s
New order, store connected, Pro expiry, and past-due alerts use the Ladill notification layout with woo branding; expiry reminders dedupe per threshold like hosting. Co-authored-by: Cursor <cursoragent@cursor.com>
65 lines
1.9 KiB
PHP
65 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Notifications\Woo;
|
|
|
|
use App\Models\Woo\ProSubscription;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Notifications\Messages\MailMessage;
|
|
use Illuminate\Notifications\Notification;
|
|
|
|
class WooProPastDueNotification extends Notification implements ShouldQueue
|
|
{
|
|
use Queueable;
|
|
|
|
public function __construct(private readonly ProSubscription $subscription) {}
|
|
|
|
public function via(object $notifiable): array
|
|
{
|
|
return $this->channels('pro_past_due');
|
|
}
|
|
|
|
public function toMail(object $notifiable): MailMessage
|
|
{
|
|
return (new MailMessage())
|
|
->subject('Woo Manager subscription payment failed')
|
|
->view('mail.notifications.woo-pro-past-due', [
|
|
'subscription' => $this->subscription,
|
|
'planLabel' => $this->planLabel(),
|
|
'renewUrl' => route('woo.pro.index'),
|
|
]);
|
|
}
|
|
|
|
/** @return array<string, mixed> */
|
|
public function toArray(object $notifiable): array
|
|
{
|
|
return [
|
|
'title' => 'Subscription payment failed',
|
|
'message' => "We could not renew your Woo Manager {$this->planLabel()} plan. Top up your wallet to restore access.",
|
|
'icon' => 'billing',
|
|
'milestone' => 'pro_past_due',
|
|
'url' => route('woo.pro.index'),
|
|
];
|
|
}
|
|
|
|
private function planLabel(): string
|
|
{
|
|
return $this->subscription->plan === ProSubscription::PLAN_ENTERPRISE ? 'Business' : 'Pro';
|
|
}
|
|
|
|
/** @return list<string> */
|
|
private function channels(string $event): array
|
|
{
|
|
$config = (array) config("notifications.woo_events.{$event}", ['mail' => true, 'database' => true]);
|
|
$channels = [];
|
|
if ($config['mail'] ?? false) {
|
|
$channels[] = 'mail';
|
|
}
|
|
if ($config['database'] ?? false) {
|
|
$channels[] = 'database';
|
|
}
|
|
|
|
return $channels ?: ['database'];
|
|
}
|
|
}
|