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 '. $e->getMessage()); } } public function show($EthnicID = null) { try { $sql = "SELECT * FROM ethnic WHERE EthnicID=$EthnicID"; $data = $this->db->query($sql)->getResultArray(); return $this->respond([ 'status' => 'success', 'message'=> "Ethnic with EthnicID $EthnicID fetched successfully", 'data' => $data, ], 200); } catch (\Exception $e) { return $this->failServerError('Something went wrong '. $e->getMessage()); } } }