41 lines
1011 B
PHP
41 lines
1011 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Api\V1;
|
|
|
|
use App\Http\Controllers\Concerns\RespondsWithJson;
|
|
use App\Http\Controllers\Controller;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Throwable;
|
|
|
|
class HealthController extends Controller
|
|
{
|
|
use RespondsWithJson;
|
|
|
|
public function index(): JsonResponse
|
|
{
|
|
return $this->success([
|
|
'status' => 'ok',
|
|
'service' => 'laverie-api',
|
|
'timestamp' => now()->toIso8601String(),
|
|
]);
|
|
}
|
|
|
|
public function database(): JsonResponse
|
|
{
|
|
try {
|
|
DB::select('SELECT 1');
|
|
|
|
return $this->success([
|
|
'status' => 'ok',
|
|
'database' => config('database.default'),
|
|
'timestamp' => now()->toIso8601String(),
|
|
]);
|
|
} catch (Throwable $e) {
|
|
return $this->error('Database connection failed', 503, [
|
|
'database' => ['Connection unavailable'],
|
|
]);
|
|
}
|
|
}
|
|
}
|