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>
59 lines
1.5 KiB
PHP
59 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Support\Str;
|
|
|
|
class Payment extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
public const PURPOSE_RESIDENT = 'resident_code_purchase';
|
|
public const PURPOSE_STORE_WHOLESALE = 'store_inventory_purchase';
|
|
|
|
public const STATUS_PENDING = 'pending';
|
|
public const STATUS_PROCESSING = 'processing';
|
|
public const STATUS_PAID = 'paid';
|
|
public const STATUS_FAILED = 'failed';
|
|
public const STATUS_REFUNDED = 'refunded';
|
|
|
|
public const PROVIDER_PAYMONGO = 'paymongo';
|
|
public const PROVIDER_MANUAL = 'manual';
|
|
|
|
protected $fillable = [
|
|
'uuid', 'payer_user_id', 'purpose', 'amount_centavos', 'currency',
|
|
'provider', 'provider_payment_id', 'status', 'provider_data',
|
|
'metadata', 'paid_at',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'amount_centavos' => 'integer',
|
|
'provider_data' => 'array',
|
|
'metadata' => 'array',
|
|
'paid_at' => 'datetime',
|
|
];
|
|
}
|
|
|
|
public function getRouteKeyName(): string
|
|
{
|
|
return 'uuid';
|
|
}
|
|
|
|
protected static function booted(): void
|
|
{
|
|
static::creating(function (self $p): void {
|
|
if (empty($p->uuid)) $p->uuid = (string) Str::uuid();
|
|
});
|
|
}
|
|
|
|
public function payer(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class, 'payer_user_id');
|
|
}
|
|
}
|