Files
Verde-Web/app/Notifications/QrBalanceLowNotification.php
admin 15d56d0e98 feat(backend): finish Module 13 sub-modules + flow fixes
Notifications: notification_preferences + Laravel notifications inbox.
SmsChannel adapter for our SmsService. RoutesByPreferences trait reads
per-user toggles. HouseholdApproved/Rejected, QrBalanceLow, and
CodesPurchased notifications wired in via auto-discovered listeners
or direct dispatch from controllers/StoreOperations.

Payments: payments table + PaymentDriver interface. ManualPaymentDriver
works out of the box; PayMongoDriver activates when
PAYMONGO_SECRET_KEY is set, falls back to manual otherwise. Resident
initiates code-purchase, admin can mark paid manually, webhook applies
real provider events. Fulfillment runs StoreOperations::sellToHousehold.

Live tracking (HTTP polling): truck_location_history (with SPATIAL
INDEX + 7-day retention plan). Driver POST /driver/trucks/{uuid}/location
writes history, updates trucks.last_known_coordinates, caches in Redis,
flags geofence-trigger when entering active trip dumpsite. Admin
GET /admin/live/trucks returns active truck positions. Reverb broadcast
deferred.

Flow corrections:
- QrAllocator now idempotent — re-approving a household no longer
  re-dispenses free codes.
- arrive-dumpsite enforces dumpsite geofence via ST_Contains; can be
  bypassed with override_geofence: true.

171 feature tests passing.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-01 14:01:38 +08:00

41 lines
1.1 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.",
];
}
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.",
];
}
}