diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 058e1ed5..9453a767 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -2519,7 +2519,7 @@ class EmployeeRestController extends AdminController public function storeFireBase() { - // try { + try { $json = $this->request->getJSON(); $firebase_token = $json->firebase_token; $mobile = $json->mobile; @@ -2565,39 +2565,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..14b61d7d 100755 --- a/app/Controllers/RestAuthenticationController.php +++ b/app/Controllers/RestAuthenticationController.php @@ -73,7 +73,9 @@ class RestAuthenticationController extends AdminController $employeeData = $this->employeeModel->where('mobile', $mobile_number) ->where('relationship', 'self') - ->where('is_active', 1)->first(); + ->where('emp_status !=', 'truncated') + ->where('is_active', 1) + ->first(); if ($employeeData) { @@ -137,7 +139,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) {