56 lines
1.6 KiB
PHP
56 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Notifications;
|
|
|
|
use App\Models\Household;
|
|
use App\Notifications\Concerns\RoutesByPreferences;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Notifications\Notification;
|
|
|
|
class QrBalanceLowNotification extends Notification
|
|
{
|
|
use Queueable, RoutesByPreferences;
|
|
|
|
public const PREF_KEY = 'low_codes_warning';
|
|
|
|
public function __construct(
|
|
public readonly Household $household,
|
|
public readonly int $activeCount,
|
|
public readonly int $threshold,
|
|
) {}
|
|
|
|
public function toArray(mixed $notifiable): array
|
|
{
|
|
return [
|
|
'type' => 'qr.balance_low',
|
|
'household_id' => $this->household->uuid,
|
|
'active_count' => $this->activeCount,
|
|
'threshold' => $this->threshold,
|
|
'message' => "You have {$this->activeCount} QR codes left. Buy more from a partner store.",
|
|
'action_label' => 'Buy Codes',
|
|
'action_url' => '/stores',
|
|
];
|
|
}
|
|
|
|
public function toSms(mixed $notifiable): array
|
|
{
|
|
return [
|
|
'to' => $notifiable->phone,
|
|
'message' => "Verde: Only {$this->activeCount} QR codes left. Buy more at any partner store before you run out.",
|
|
];
|
|
}
|
|
|
|
public function toPush(mixed $notifiable): array
|
|
{
|
|
return [
|
|
'title' => 'QR codes running low',
|
|
'body' => "Only {$this->activeCount} codes left. Buy more at a partner store.",
|
|
'data' => [
|
|
'type' => 'qr.balance_low',
|
|
'household_id' => $this->household->uuid,
|
|
'active_count' => $this->activeCount,
|
|
],
|
|
];
|
|
}
|
|
}
|