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>
54 lines
2.0 KiB
PHP
54 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Api\V1\Auth;
|
|
|
|
use App\Http\Controllers\Api\V1\ApiController;
|
|
use App\Models\NotificationPreference;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Request;
|
|
|
|
class NotificationPreferencesController extends ApiController
|
|
{
|
|
public function show(Request $request): JsonResponse
|
|
{
|
|
$prefs = NotificationPreference::firstOrCreate(
|
|
['user_id' => $request->user()->id],
|
|
['language' => $request->user()->preferred_language ?? 'en'],
|
|
);
|
|
|
|
return $this->ok($prefs->only([
|
|
'pickup_reminder', 'pickup_imminent', 'pickup_completed',
|
|
'low_codes_warning', 'codes_purchased', 'schedule_changed',
|
|
'household_status',
|
|
'sms_enabled', 'email_enabled', 'push_enabled', 'language',
|
|
]));
|
|
}
|
|
|
|
public function update(Request $request): JsonResponse
|
|
{
|
|
$data = $request->validate([
|
|
'pickup_reminder' => ['sometimes', 'boolean'],
|
|
'pickup_imminent' => ['sometimes', 'boolean'],
|
|
'pickup_completed' => ['sometimes', 'boolean'],
|
|
'low_codes_warning' => ['sometimes', 'boolean'],
|
|
'codes_purchased' => ['sometimes', 'boolean'],
|
|
'schedule_changed' => ['sometimes', 'boolean'],
|
|
'household_status' => ['sometimes', 'boolean'],
|
|
'sms_enabled' => ['sometimes', 'boolean'],
|
|
'email_enabled' => ['sometimes', 'boolean'],
|
|
'push_enabled' => ['sometimes', 'boolean'],
|
|
'language' => ['sometimes', 'in:en,tl,ceb'],
|
|
]);
|
|
|
|
$prefs = NotificationPreference::firstOrCreate(['user_id' => $request->user()->id]);
|
|
$prefs->update($data);
|
|
|
|
return $this->ok($prefs->fresh()->only([
|
|
'pickup_reminder', 'pickup_imminent', 'pickup_completed',
|
|
'low_codes_warning', 'codes_purchased', 'schedule_changed',
|
|
'household_status',
|
|
'sms_enabled', 'email_enabled', 'push_enabled', 'language',
|
|
]), 'Preferences updated');
|
|
}
|
|
}
|