add projet
This commit is contained in:
+27
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class TestDBController extends BaseApiController
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
try {
|
||||
$result = DB::select('SELECT 1 AS ok');
|
||||
if (!empty($result)) {
|
||||
return $this->success(['message' => 'Database connection is successful.'], 'Database check completed');
|
||||
}
|
||||
|
||||
return $this->respondError('Database connection failed', Response::HTTP_INTERNAL_SERVER_ERROR);
|
||||
} catch (QueryException $e) {
|
||||
return $this->respondError(
|
||||
'Database connection failed: ' . $e->getMessage(),
|
||||
Response::HTTP_INTERNAL_SERVER_ERROR
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user