diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 2652364..a8fdf30 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -21,6 +21,13 @@ $routes->delete('/api/patient/(:num)', 'Patient::delete/$1'); $routes->patch('/api/patient/(:num)', 'Patient::update/$1'); $routes->get('/api/race', 'Race::index'); +$routes->get('/api/race/(:num)', 'Race::show/$1'); + $routes->get('/api/country', 'Country::index'); +$routes->get('/api/country/(:num)', 'Country::show/$1'); + $routes->get('/api/religion', 'Religion::index'); -$routes->get('/api/ethnic', 'Ethnic::index'); \ No newline at end of file +$routes->get('/api/religion/(:num)', 'Religion::show/$1'); + +$routes->get('/api/ethnic', 'Ethnic::index'); +$routes->get('/api/ethnic/(:num)', 'Ethnic::show/$1'); \ No newline at end of file diff --git a/app/Controllers/Country.php b/app/Controllers/Country.php index 4fe474b..a0687ec 100644 --- a/app/Controllers/Country.php +++ b/app/Controllers/Country.php @@ -31,7 +31,24 @@ class Country extends Controller { 'data' => $data, ], 200); } catch (\Exception $e) { - return $this->failServerError('Something went wrong'); + return $this->failServerError('Something went wrong '.$e->getMessage()); } } + + public function show($IntCountryID = null) { + try { + + $sql = "SELECT IntCountryID, CountryID, Country FROM country WHERE IntCountryID = $IntCountryID"; + $data = $this->db->query($sql)->getResultArray(); + + return $this->respond([ + 'status' => 'success', + 'message'=> "Country with IntCountryID $IntCountryID fetched successfully", + 'data' => $data, + ], 200); + } catch (\Exception $e) { + return $this->failServerError('Something went wrong '.$e->getMessage()); + } + } + } \ No newline at end of file diff --git a/app/Controllers/Ethnic.php b/app/Controllers/Ethnic.php index a3e7a9d..9ba74e9 100644 --- a/app/Controllers/Ethnic.php +++ b/app/Controllers/Ethnic.php @@ -13,16 +13,31 @@ class Ethnic extends Controller { public function index() { try { - $sql = "select * from ethnic"; + $sql = "SELECT * FROM ethnic"; $data = $this->db->query($sql)->getResultArray(); - return $this->respond([ - 'status' => 'success', - 'message'=> "Ethnic fetched successfully", - 'data' => $data, - ], 200); + return $this->respond([ + 'status' => 'success', + 'message'=> "Ethnic fetched successfully", + 'data' => $data, + ], 200); } catch (\Exception $e) { - return $this->failServerError('Something went wrong'); + 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()); } } } \ No newline at end of file diff --git a/app/Controllers/Race.php b/app/Controllers/Race.php index 4de87be..cac0370 100644 --- a/app/Controllers/Race.php +++ b/app/Controllers/Race.php @@ -13,16 +13,31 @@ class Race extends Controller { public function index() { try { - $sql = "select * from race"; + $sql = "SELECT * FROM race"; $data = $this->db->query($sql)->getResultArray(); - return $this->respond([ - 'status' => 'success', - 'message'=> "Race fetched successfully", - 'data' => $data, - ], 200); + return $this->respond([ + 'status' => 'success', + 'message'=> "Race fetched successfully", + 'data' => $data, + ], 200); } catch (\Exception $e) { - return $this->failServerError('Something went wrong'); + return $this->failServerError('Something went wrong'. $e->getMessage()); + } + } + + public function show($RaceID = null) { + try { + $sql = "SELECT * FROM race WHERE RacrID = $RaceID"; + $data = $this->db->query($sql)->getResultArray(); + + return $this->respond([ + 'status' => 'success', + 'message'=> "Race with RaceID $RaceID fetched successfully", + 'data' => $data, + ], 200); + } catch (\Exception $e) { + return $this->failServerError('Something went wrong'. $e->getMessage()); } } } \ No newline at end of file diff --git a/app/Controllers/Religion.php b/app/Controllers/Religion.php index 29fbd89..584d52e 100644 --- a/app/Controllers/Religion.php +++ b/app/Controllers/Religion.php @@ -12,17 +12,32 @@ class Religion extends Controller { } public function index() { - try { - $sql = "select * from religion"; - $data = $this->db->query($sql)->getResultArray(); + try { + $sql = "SELECT * FROM religion"; + $data = $this->db->query($sql)->getResultArray(); - return $this->respond([ - 'status' => 'success', - 'message'=> "Religion fetched successfully", - 'data' => $data, - ], 200); - } catch (\Exception $e) { - return $this->failServerError('Something went wrong'); + return $this->respond([ + 'status' => 'success', + 'message'=> "Religion fetched successfully", + 'data' => $data, + ], 200); + } catch (\Exception $e) { + return $this->failServerError('Something went wrong '. $e->getMessage()); + } } + + public function show($ReligionID = null) { + try { + $sql = "SELECT * FROM religion WHERE ReligionID = $ReligionID"; + $data = $this->db->query($sql)->getResultArray(); + + return $this->respond([ + 'status' => 'success', + 'message'=> "Religion with ReligionID $ReligionID fetched successfully", + 'data' => $data, + ], 200); + } catch (\Exception $e) { + return $this->failServerError('Something went wrong '.$e->getMessage()); + } } } \ No newline at end of file