Files
Verde-Web/app/Providers/AppServiceProvider.php
admin 86ea731eb0 feat(backend): finish all deferred items — Sentry, audit, bulk, FCM, Reverb, PSGC
- **Sentry** wired in bootstrap/app.php via Sentry\Laravel\Integration.
  No-op when SENTRY_LARAVEL_DSN is empty.

- **Audit logging** broadened: LogsActivity applied to Household, QrCode,
  Trip, Payment with tight logOnly whitelists and named log channels
  ('household', 'qr_code', 'trip', 'payment') to keep the activity
  stream useful.

- **Bulk admin actions**:
  POST /admin/households/bulk-approve — skips already-approved /
  no-proof / unknown ids, reports per-id outcomes
  POST /admin/bulk/users/{suspend,activate} — admins protected
  POST /admin/bulk/qr-codes/void — respects state machine transitions

- **FCM push scaffold**: PushDriver contract with LogPushDriver
  (default) and FcmPushDriver (activates when FCM_SERVER_KEY is set).
  PushChannel adapts notifications. RoutesByPreferences now also
  routes via push when push_enabled + fcm_token. toPush() payloads
  added to HouseholdApproved / QrBalanceLow / PickupImminent.

- **Reverb WebSocket broadcast**: laravel/reverb installed.
  TruckLocationBroadcast fires on every TruckTracker::record().
  routes/channels.php authenticates: admins → private-admin.live,
  residents → area.{id}.trucks (only if their household barangay is
  covered by the service area).

- **PSGC seeder** expanded: all 17 PH regions, 4 NCR districts,
  all 17 NCR cities. Sample barangays still carry rectangular
  boundaries for point-in-polygon resolution tests.

- **Conditional SPATIAL INDEX migration** for barangays.boundary —
  safe no-op until every row has a polygon (i.e., after full PSA
  dataset import). Re-running `php artisan migrate` after import
  flips the column to NOT NULL and adds the index.

196 feature tests passing.

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

69 lines
2.3 KiB
PHP

<?php
namespace App\Providers;
use App\Services\Payment\ManualPaymentDriver;
use App\Services\Payment\PayMongoDriver;
use App\Services\Payment\PaymentDriver;
use App\Services\Push\FcmPushDriver;
use App\Services\Push\LogPushDriver;
use App\Services\Push\PushDriver;
use App\Services\Sms\FakeSmsService;
use App\Services\Sms\LogSmsService;
use App\Services\Sms\SemaphoreSmsService;
use App\Services\Sms\SmsService;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
public function register(): void
{
$this->app->singleton(PaymentDriver::class, function ($app) {
$driver = config('services.payments.driver', 'manual');
$key = (string) config('services.paymongo.secret_key');
if ($driver === 'paymongo' && $key !== '') {
return new PayMongoDriver(
secretKey: $key,
webhookSecret: (string) config('services.paymongo.webhook_secret'),
successUrl: (string) config('services.paymongo.success_url'),
cancelUrl: (string) config('services.paymongo.cancel_url'),
);
}
return new ManualPaymentDriver();
});
$this->app->singleton(PushDriver::class, function ($app) {
$driver = config('services.push.driver', 'log');
$key = (string) config('services.fcm.server_key');
if ($driver === 'fcm' && $key !== '') {
return new FcmPushDriver($key);
}
return new LogPushDriver();
});
$this->app->singleton(SmsService::class, function ($app) {
$driver = config('services.sms.driver', 'log');
return match ($driver) {
'semaphore' => new SemaphoreSmsService(
apiKey: (string) config('services.semaphore.api_key'),
senderName: (string) config('services.semaphore.sender_name', 'VERDE'),
),
'fake' => new FakeSmsService(),
default => new LogSmsService(),
};
});
}
public function boot(): void
{
// Listeners under App\Listeners are auto-discovered by Laravel 11
// based on their handle() method's type-hint. Don't register them
// explicitly here — that causes double-dispatch.
}
}