CHANGES-in-restApi:GWM

This commit is contained in:
bitbucket 2024-03-19 11:39:08 +05:30
parent 62eec1f44c
commit f99c0ca5e2
3 changed files with 19 additions and 20 deletions

View File

@ -213,7 +213,7 @@ $routes->post("/editEmployeeProfile", "EmployeeRestController::editEmployeeProfi
$routes->get("getClientPolicy", "EmployeeRestController::getClientPolicy");
$routes->group("employeeRest", ["filter" => "authJWT"], function($routes){ $routes->group("employeeRest", ["filter" => "authJWT"], function($routes){

View File

@ -211,29 +211,28 @@ class EmployeeRestController extends AdminController
public function getEmployeeAndDependenceByClientId() public function getEmployeeAndDependenceByClientId()
{ {
try { try {
$empData = $this->employeeModel
->where('client_id', $this->request->getGet('client_id')) $empData = $this->employeeModel->where('client_id', $this->request->getGet('client_id'))
->where('relationship', 'self') ->where('relationship !=', null)
->orderBy('id') ->orderBy('emp_code')->orderBy('id')->findAll();
->findAll();
$result = []; // $result = [];
foreach ($empData as $employee) { // foreach ($empData as $employee) {
$employeeDependence = $this->employeeModel // $employeeDependence = $this->employeeModel
->where('emp_code', $employee['emp_code']) // ->where('emp_code', $employee['emp_code'])
->where('relationship !=', 'self') // ->where('relationship !=', 'self')
->findAll(); // ->findAll();
// Use object notation to access properties and set 'dependence' // // Use object notation to access properties and set 'dependence'
$employee['dependence'] = $employeeDependence ?: []; // $employee['dependence'] = $employeeDependence ?: [];
$result[] = $employee; // $result[] = $employee;
} // }
// You probably meant to check $result, not $data // You probably meant to check $result, not $data
if ($result) { if ($empData) {
return $this->respond(['status' => 'success', 'code' => 200, 'data' => $result], 200); return $this->respond(['status' => 'success', 'code' => 200, 'data' => $empData], 200);
} else { } else {
return $this->respond(['status' => 'failed', 'code' => 404, 'data' => []], 404); return $this->respond(['status' => 'failed', 'code' => 404, 'data' => []], 404);
} }
@ -248,7 +247,7 @@ class EmployeeRestController extends AdminController
public function getClientPolicy() public function getClientPolicy()
{ {
try { 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') $ClientPolicyData = $this->clientPolicyModel->select('client_policy.id as client_policy_id , client_policy.client_id as client_id, policies.id as policy_id,policies.policy_type_id as policy_type_id, policies.name as policy_name')
->join('policies', 'client_policy.policy_id = policies.id', 'left') ->join('policies', 'client_policy.policy_id = policies.id', 'left')
->where('client_policy.client_id', $this->request->getGet('client_id') ) ->where('client_policy.client_id', $this->request->getGet('client_id') )
->findAll(); ->findAll();

View File

@ -176,7 +176,7 @@ class RestAuthenticationController extends AdminController
->where('level_contacts.mobile', $mobile_number ) ->where('level_contacts.mobile', $mobile_number )
->find(); ->find();
$result = JWTToken::encode($hrData); $result = JWTToken::encode($hrData['0']);
return $this->respond(['status' => 'success','code' => 200,'data' => $result],200); return $this->respond(['status' => 'success','code' => 200,'data' => $result],200);
} else { } else {
return $this->respond(['status' => 'failed','code' => 404,'data' => "No data"],404); return $this->respond(['status' => 'failed','code' => 404,'data' => "No data"],404);