user = $user; $this->sant = $sant; $this->senBackDesc = $senBackDesc; } /** * Execute the job. * * @return void */ public function handle() { try { //Push Notification to shravak who added $tokens = UserDeviceToken::where('user_id', $this->sant->updated_by)->get()->toArray(); $pushData = []; $users = []; if($tokens && $tokens > 0) { foreach ($tokens as $token) { $pushData['userToken'] = $token['token'] ?? []; $pushData['title'] = trans('notifications.notification_title.sant_send_back',['sant' => $this->sant->name]); $pushData['body'] = trans('notifications.push_sant.sant_send_back'); $pushData['image'] = ($this->user->avatar) ? $this->user->avatar : ""; $pushData['from_id'] = $this->sant->sant_id; $extraData = []; $extraData['user_id'] = $this->user->id ?? ''; $extraData['user_name'] = $this->user->name ?? ''; $extraData['user_type'] = 'sant'; $extraData['type'] = trans('notifications.sant_notification_type.sant-send-back'); $extraData['created_at'] = date('Y/m/d H:i:s'); $extraData['os'] = $token['os'] ? getPlatform($token['os']) : []; $pushData['extraData'] = $extraData ?? []; $this->pushNotification($pushData, $extraData); } } //Store notification for send back sant $notificationData = []; $notificationData['body'] = trans('notifications.sant.sant_send_back',['reason' => $this->senBackDesc]); $notificationData['user_id'] = $this->sant->updated_by; $notificationData['type'] = trans('notifications.sant_notification_type.sant-send-back'); $notificationData['title'] = trans('notifications.notification_title.sant_send_back',['sant' => $this->sant->name]); $extraNotificationData = []; $extraNotificationData['from_id'] = $this->sant->sant_id ?? ''; $extraNotificationData['user_id'] = $this->user->id ?? ''; $extraNotificationData['name'] = $this->sant->name ?? ''; $extraNotificationData['avatar'] = ($this->sant->avatar) ? $this->sant->avatar : ""; $extraNotificationData['user_type'] = 'sant'; $extraNotificationData['created_at'] = date('Y/m/d H:i:s'); $notificationData['extraNotificationData'] = $extraNotificationData ?? []; if (!in_array($this->sant->updated_by, $users)) { $users[$this->sant->updated_by] = $this->sant->updated_by; $this->storeNotification($notificationData); unreadNotificationCounter($this->sant->updated_by); //Unread count increament unreadSantActionCounter($this->sant->updated_by, Constant::STATUS_ONE); //Pending sant action badge unreadSantMenuCounter($this->sant->updated_by, Constant::STATUS_ONE); //Pending sant menu badge } } catch (\Exception $ex) { Log::error($ex); } } }