clqms-be/app/Controllers/Ethnic.php

28 lines
616 B
PHP
Raw Normal View History

2025-08-01 11:37:03 +07:00
<?php
namespace App\Controllers;
use CodeIgniter\API\ResponseTrait;
use CodeIgniter\Controller;
class Ethnic extends Controller {
use ResponseTrait;
public function __construct() {
$this->db = \Config\Database::connect();
}
public function index() {
try {
$sql = "select * from ethnic";
$data = $this->db->query($sql)->getResultArray();
return $this->respond([
'status' => 'success',
'message'=> "Ethnic fetched successfully",
'data' => $data,
], 200);
} catch (\Exception $e) {
return $this->failServerError('Something went wrong');
}
}
}