From 894f1357a97b254292724121208a6a37037340bc Mon Sep 17 00:00:00 2001 From: Gowtham M Date: Thu, 28 Nov 2024 09:20:02 +0530 Subject: [PATCH 1/2] CHANGE_in emp login api added additional where condition : GWM --- app/Controllers/EmployeeRestController.php | 64 +++++++++---------- .../RestAuthenticationController.php | 4 +- 2 files changed, 35 insertions(+), 33 deletions(-) diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 0684f727..f0f1925e 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -2502,7 +2502,7 @@ class EmployeeRestController extends AdminController public function storeFireBase() { - // try { + try { $json = $this->request->getJSON(); $firebase_token = $json->firebase_token; $mobile = $json->mobile; @@ -2548,39 +2548,39 @@ class EmployeeRestController extends AdminController } else { return $this->respond(['status' => 'failed', 'code' => 404, 'message' => 'Employee not found'], 404); } - // } catch (\Throwable $th) { - // log_message('error', 'An error occurred: ' . $th->getMessage()); - // return $this->respond(['status' => 'failed', 'code' => 500, 'message' => 'An error occurred', 'error' => $th->getMessage()], 500); - // } - } - - - - - - public function sendPushNotification() - { - $deviceToken = 'cMVKESh8QzqIl8nh_yqbcl:APA91bHKm87Sh1goVJNKZtctV4etgLMQboI0eyDVn3MH1yf9cO-2RtQRlFnKLdataOxosoxm7a4JvATKjfI1_Bids46mGw5m8zesp90mR4odCbD_cJtGmBeMYt4hssSY0YtAht1emK_H'; - $title = 'Nhance'; - $body = 'All your policy enrolled successfully ..!'; - - // Initialize Firebase with the service account - $firebase = (new Factory) - ->withServiceAccount(APPPATH . 'Config/google-services.json') - ->createMessaging(); - - $notification = Notification::create($title, $body); - $message = CloudMessage::withTarget('token', $deviceToken) - ->withNotification($notification); - - try { - $firebase->send($message); - return $this->response->setJSON(['status' => 'success']); - } catch (MessagingException $e) { - //return $this->response->setJSON(['status' => 'error', 'message' => $e->getMessage()]); - log_message('error', $e->getMessage()); + } catch (\Throwable $th) { + log_message('error', 'An error occurred: ' . $th->getMessage()); + return $this->respond(['status' => 'failed', 'code' => 500, 'message' => 'An error occurred', 'error' => $th->getMessage()], 500); } } + + + + + + // public function sendPushNotification() + // { + // $deviceToken = 'cMVKESh8QzqIl8nh_yqbcl:APA91bHKm87Sh1goVJNKZtctV4etgLMQboI0eyDVn3MH1yf9cO-2RtQRlFnKLdataOxosoxm7a4JvATKjfI1_Bids46mGw5m8zesp90mR4odCbD_cJtGmBeMYt4hssSY0YtAht1emK_H'; + // $title = 'Nhance'; + // $body = 'All your policy enrolled successfully ..!'; + + // // Initialize Firebase with the service account + // $firebase = (new Factory) + // ->withServiceAccount(APPPATH . 'Config/google-services.json') + // ->createMessaging(); + + // $notification = Notification::create($title, $body); + // $message = CloudMessage::withTarget('token', $deviceToken) + // ->withNotification($notification); + + // try { + // $firebase->send($message); + // return $this->response->setJSON(['status' => 'success']); + // } catch (MessagingException $e) { + // //return $this->response->setJSON(['status' => 'error', 'message' => $e->getMessage()]); + // log_message('error', $e->getMessage()); + // } + // } diff --git a/app/Controllers/RestAuthenticationController.php b/app/Controllers/RestAuthenticationController.php index bed2e473..737265cf 100755 --- a/app/Controllers/RestAuthenticationController.php +++ b/app/Controllers/RestAuthenticationController.php @@ -73,6 +73,7 @@ class RestAuthenticationController extends AdminController $employeeData = $this->employeeModel->where('mobile', $mobile_number) ->where('relationship', 'self') + ->where('emp_status !=', 'truncated') ->where('is_active', 1)->first(); if ($employeeData) { @@ -137,7 +138,8 @@ class RestAuthenticationController extends AdminController $HrData = $this->hrModel->where('mobile', $mobile_number) ->where('contact_type', 'client') - ->where('is_active', 1)->first(); + ->where('is_active', 1) + ->first(); if ($HrData) { From bb033fa8be97bc54cd896d5a9fb876363c307544 Mon Sep 17 00:00:00 2001 From: Gowtham M Date: Thu, 28 Nov 2024 09:24:13 +0530 Subject: [PATCH 2/2] CHANGE_in emp login api added additional where condition : GWM --- app/Controllers/RestAuthenticationController.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Controllers/RestAuthenticationController.php b/app/Controllers/RestAuthenticationController.php index 737265cf..14b61d7d 100755 --- a/app/Controllers/RestAuthenticationController.php +++ b/app/Controllers/RestAuthenticationController.php @@ -74,7 +74,8 @@ class RestAuthenticationController extends AdminController $employeeData = $this->employeeModel->where('mobile', $mobile_number) ->where('relationship', 'self') ->where('emp_status !=', 'truncated') - ->where('is_active', 1)->first(); + ->where('is_active', 1) + ->first(); if ($employeeData) {