From 62eec1f44c3caf44bae0c82425a45d4f5758b501 Mon Sep 17 00:00:00 2001 From: bitbucket Date: Mon, 18 Mar 2024 20:09:46 +0530 Subject: [PATCH] GWM:CHANGE-IN-REST-API --- app/Config/Routes.php | 1 + app/Controllers/EmployeeRestController.php | 24 +++++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 74688631..45cf2568 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -227,6 +227,7 @@ $routes->group("employeeRest", ["filter" => "authJWT"], function($routes){ $routes->post("createOrUpdateEmployeePolicySiAmount", "EmployeeRestController::createOrUpdateEmployeePolicySiAmount"); $routes->get("deleteDependence", "EmployeeRestController::deleteDependence"); $routes->get("getEmployeeAndDependenceByClientId", "EmployeeRestController::getEmployeeAndDependenceByClientId"); + $routes->get("getClientPolicy", "EmployeeRestController::getClientPolicy"); }); $routes->post("sendEmail", "EmployeeRestController::send_email"); diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 0f9e82f1..44a17c02 100644 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -52,7 +52,7 @@ class EmployeeRestController extends AdminController $this->policesModel = new PolicesModel(); $this->relationshipModel = new RelationshipModel(); $this->fileModel= new FileModel(); - $this->clientPolicyModel= new ClientPolicyModel(); + $this->clientPolicyModel = new ClientPolicyModel(); } @@ -245,6 +245,28 @@ class EmployeeRestController extends AdminController } + public function getClientPolicy() + { + try { + $ClientPolicyData = $this->clientPolicyModel->select('client_policy.id as client_policy_id , client_policy.client_id as client_id,, policies.id as policy_id, policies.name as policy_name') + ->join('policies', 'client_policy.policy_id = policies.id', 'left') + ->where('client_policy.client_id', $this->request->getGet('client_id') ) + ->findAll(); + + // You probably meant to check $result, not $data + if ($ClientPolicyData) { + return $this->respond(['status' => 'success', 'code' => 200, 'data' => $ClientPolicyData], 200); + } else { + return $this->respond(['status' => 'failed', 'code' => 404, 'data' => []], 404); + } + + + } catch (\Exception $e) { + return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()], 500); + } + + } + public function getEmployeePolicy() {