- **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>
75 lines
2.8 KiB
PHP
75 lines
2.8 KiB
PHP
<?php
|
|
|
|
use App\Http\Responses\ApiResponse;
|
|
use Illuminate\Auth\AuthenticationException;
|
|
use Illuminate\Foundation\Application;
|
|
use Illuminate\Foundation\Configuration\Exceptions;
|
|
use Illuminate\Foundation\Configuration\Middleware;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Validation\ValidationException;
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
|
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
|
|
|
return Application::configure(basePath: dirname(__DIR__))
|
|
->withRouting(
|
|
web: __DIR__.'/../routes/web.php',
|
|
api: __DIR__.'/../routes/api.php',
|
|
apiPrefix: 'api/v1',
|
|
commands: __DIR__.'/../routes/console.php',
|
|
channels: __DIR__.'/../routes/channels.php',
|
|
health: '/up',
|
|
)
|
|
->withMiddleware(function (Middleware $middleware) {
|
|
$middleware->statefulApi();
|
|
|
|
$middleware->alias([
|
|
'role' => \App\Http\Middleware\EnsureUserHasRole::class,
|
|
]);
|
|
|
|
$middleware->redirectGuestsTo(function (Request $request) {
|
|
return $request->is('api/*') ? null : null;
|
|
});
|
|
})
|
|
->withExceptions(function (Exceptions $exceptions) {
|
|
// Report unhandled exceptions to Sentry. No-op when SENTRY_LARAVEL_DSN
|
|
// isn't set (e.g., local/testing) — keeps the dev loop quiet.
|
|
\Sentry\Laravel\Integration::handles($exceptions);
|
|
|
|
$exceptions->shouldRenderJsonWhen(function (Request $request) {
|
|
return $request->is('api/*') || $request->expectsJson();
|
|
});
|
|
|
|
$exceptions->render(function (ValidationException $e, Request $request) {
|
|
if ($request->is('api/*') || $request->expectsJson()) {
|
|
return ApiResponse::error(
|
|
'Validation failed',
|
|
$e->errors(),
|
|
Response::HTTP_UNPROCESSABLE_ENTITY,
|
|
);
|
|
}
|
|
});
|
|
|
|
$exceptions->render(function (AuthenticationException $e, Request $request) {
|
|
if ($request->is('api/*') || $request->expectsJson()) {
|
|
return ApiResponse::error('Unauthenticated', null, Response::HTTP_UNAUTHORIZED);
|
|
}
|
|
});
|
|
|
|
$exceptions->render(function (NotFoundHttpException $e, Request $request) {
|
|
if ($request->is('api/*') || $request->expectsJson()) {
|
|
return ApiResponse::error('Resource not found', null, Response::HTTP_NOT_FOUND);
|
|
}
|
|
});
|
|
|
|
$exceptions->render(function (HttpExceptionInterface $e, Request $request) {
|
|
if ($request->is('api/*') || $request->expectsJson()) {
|
|
return ApiResponse::error(
|
|
$e->getMessage() ?: 'Request failed',
|
|
null,
|
|
$e->getStatusCode(),
|
|
);
|
|
}
|
|
});
|
|
})->create();
|