- Laravel 11.51 + PHP 8.4 in backend/
- MySQL 9 connection (DBngin, db: verde)
- Installed Sanctum, Spatie permission/activitylog/model-states,
matanyadaev/laravel-eloquent-spatial
- API routes prefixed /api/v1 in bootstrap/app.php
- Standard response envelope { success, data, message, errors, meta }
via ApiResponse + ApiController base class
- Global exception handlers for validation/auth/not-found/http errors
on api/* routes (always JSON, never redirect to login)
- Extended users migration: uuid, phone+verified_at, role enum
(admin/resident/driver/helper/scanner/store_partner), status,
first/middle/last name, avatar_path, preferred_language, fcm_token,
last_login_at, soft deletes
- User model: HasApiTokens, HasRoles, LogsActivity, SoftDeletes,
role/status constants, auto-uuid on create
- Health endpoint at GET /api/v1/health verifies DB connection
- backend/CLAUDE.md documenting backend conventions
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
35 lines
875 B
PHP
35 lines
875 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Api\V1;
|
|
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Throwable;
|
|
|
|
class HealthController extends ApiController
|
|
{
|
|
public function __invoke(): JsonResponse
|
|
{
|
|
$database = $this->checkDatabase();
|
|
|
|
return $this->ok([
|
|
'service' => config('app.name'),
|
|
'environment' => config('app.env'),
|
|
'version' => 'v1',
|
|
'database' => $database,
|
|
'timestamp' => now()->toIso8601String(),
|
|
], 'Service is healthy');
|
|
}
|
|
|
|
private function checkDatabase(): array
|
|
{
|
|
try {
|
|
DB::connection()->getPdo();
|
|
|
|
return ['status' => 'ok', 'driver' => DB::connection()->getDriverName()];
|
|
} catch (Throwable $e) {
|
|
return ['status' => 'error', 'message' => 'Connection failed'];
|
|
}
|
|
}
|
|
}
|