Files
Verde-Web/app/Notifications/CodesPurchased.php

45 lines
1.3 KiB
PHP

<?php
namespace App\Notifications;
use App\Notifications\Concerns\RoutesByPreferences;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
class CodesPurchased extends Notification
{
use Queueable, RoutesByPreferences;
public const PREF_KEY = 'codes_purchased';
public function __construct(
public readonly int $quantity,
public readonly int $totalCentavos,
public readonly string $sourceName,
public readonly int $saleId,
) {}
public function toArray(mixed $notifiable): array
{
return [
'type' => 'qr.codes_purchased',
'quantity' => $this->quantity,
'total_centavos' => $this->totalCentavos,
'source' => $this->sourceName,
'sale_id' => $this->saleId,
'message' => "{$this->quantity} QR codes added to your wallet from {$this->sourceName}.",
'receipt_url' => route('api.v1.me.sales.receipt', $this->saleId),
];
}
public function toSms(mixed $notifiable): array
{
$pesos = number_format($this->totalCentavos / 100, 2);
return [
'to' => $notifiable->phone,
'message' => "Verde: {$this->quantity} codes added to your wallet (₱{$pesos}, from {$this->sourceName}).",
];
}
}