diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 1d74b98..8af7681 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -257,12 +257,13 @@ $routes->group('', ['filter' => 'cors'], function($routes) { // REST API $routes->get('/api/zones', 'Api\ZonesApi::getAll'); +$routes->get('/api/contacts', 'Api\ContactsApi::getAll'); // $routes->get('/api/provinces', 'Api\ZonesApi::getProvinces'); // $routes->get('/api/cities', 'Api\ZonesApi::getCities'); $routes->get('/api/getProductAlias', 'Api::getProductAlias'); $routes->get('/api/getProductSites', 'Api::getProductSites'); -$routes->get('/api/getProvinces', 'Api::getProvinces'); -$routes->get('/api/getCities', 'Api::getCities'); +// $routes->get('/api/getProvinces', 'Api::getProvinces'); +// $routes->get('/api/getCities', 'Api::getCities'); //CLQMS diff --git a/app/Controllers/Api/ContactsApi.php b/app/Controllers/Api/ContactsApi.php new file mode 100644 index 0000000..8a4da0b --- /dev/null +++ b/app/Controllers/Api/ContactsApi.php @@ -0,0 +1,47 @@ +model = new ContactsModel(); + } + + public function getAll() { + $rows = $this->model->getAll(); + + if (empty($rows)) { return $this->respond([ 'status' => 'success', 'message' => "data not found", 'data' => [] ], 200); } + return $this->respond([ 'status' => 'success', 'message'=> "Data fetched successfully", 'data' => $rows ], 200); + } + + // public function getProvinces() { + // // $filters = [ + // // 'zoneid' => $this->request->getVar('zoneid') ?? null, + // // 'zonename' => $this->request->getVar('zonename') ?? null + // // ]; + + // $rows = $this->model->getAllProvinces(); + + // if (empty($rows)) { return $this->respond([ 'status' => 'success', 'message' => "data not found", 'data' => [] ], 200); } + // return $this->respond([ 'status' => 'success', 'message'=> "Data fetched successfully", 'data' => $rows ], 200); + // } + + // public function getCities() { + + // $filter = [ + // 'zoneid' => $this->request->getVar('zoneid') ?? null + // ]; + + // $rows = $this->model->getAllCities($filter); + + // if (empty($rows)) { return $this->respond([ 'status' => 'success', 'message' => "data not found", 'data' => [] ], 200); } + // return $this->respond([ 'status' => 'success', 'message'=> "Data fetched successfully", 'data' => $rows ], 200); + // } +} \ No newline at end of file diff --git a/app/Models/ContactsModel.php b/app/Models/ContactsModel.php index adf6235..7af8861 100644 --- a/app/Models/ContactsModel.php +++ b/app/Models/ContactsModel.php @@ -8,4 +8,8 @@ class ContactsModel extends Model { protected $allowedFields = [ 'firstname', 'lastname', 'title', 'initial', 'birthdate', 'email_1', 'email_2', 'phone', 'mobile_1', 'mobile_2', 'createdate', 'enddate' ]; + + public function getAll() { + return $this->findAll(); + } } \ No newline at end of file