53 lines
1.7 KiB
PHP
53 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Notifications;
|
|
|
|
use App\Models\Household;
|
|
use App\Notifications\Concerns\RoutesByPreferences;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Notifications\Notification;
|
|
|
|
class HouseholdApproved extends Notification
|
|
{
|
|
use Queueable, RoutesByPreferences;
|
|
|
|
public const PREF_KEY = 'household_status';
|
|
|
|
public function __construct(public readonly Household $household, public readonly int $codesAllocated = 0) {}
|
|
|
|
public function toArray(mixed $notifiable): array
|
|
{
|
|
return [
|
|
'type' => 'household.approved',
|
|
'household_id' => $this->household->uuid,
|
|
'codes_allocated' => $this->codesAllocated,
|
|
'message' => "Your household {$this->household->address_line} is verified."
|
|
.($this->codesAllocated > 0 ? " {$this->codesAllocated} free QR codes are ready." : ''),
|
|
];
|
|
}
|
|
|
|
public function toSms(mixed $notifiable): array
|
|
{
|
|
return [
|
|
'to' => $notifiable->phone,
|
|
'message' => 'Verde: Your household is verified.'
|
|
.($this->codesAllocated > 0 ? " {$this->codesAllocated} QR codes are ready in your wallet." : '')
|
|
.' Open the app to see details.',
|
|
];
|
|
}
|
|
|
|
public function toPush(mixed $notifiable): array
|
|
{
|
|
return [
|
|
'title' => 'Household verified',
|
|
'body' => $this->codesAllocated > 0
|
|
? "{$this->codesAllocated} QR codes ready in your wallet."
|
|
: 'Your household has been verified.',
|
|
'data' => [
|
|
'type' => 'household.approved',
|
|
'household_id' => $this->household->uuid,
|
|
],
|
|
];
|
|
}
|
|
}
|