sant = $sant; $this->user = $user; } /** * Execute the job. * * @return void */ public function handle() { try { //Push Notification to shravak who added $tokens = UserDeviceToken::where('user_id', $this->user->id)->get()->toArray(); $data = []; $users = []; if($tokens && $tokens > 0) { foreach ($tokens as $token) { $data['userToken'] = $token['token'] ?? []; $data['title'] = trans('notifications.notification_title.chaturmas_rejected',['sant' => $this->sant->name]); $data['body'] = trans('notifications.sant.chaturmas_rejected'); $data['image'] = ($this->sant->avatar) ? $this->sant->avatar : ""; $data['from_id'] = $this->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.chaturmas-rejected'); $extraData['created_at'] = date('Y/m/d H:i:s'); $extraData['os'] = $token['os'] ? getPlatform($token['os']) : []; $data['extraData'] = $extraData ?? []; $this->pushNotification($data, $extraData); } } //Store notification for reject chaturmas $notificationData = []; $notificationData['body'] = trans('notifications.sant.chaturmas_rejected'); $notificationData['user_id'] = $this->user->id; $notificationData['type'] = trans('notifications.sant_notification_type.chaturmas-rejected'); $notificationData['title'] = trans('notifications.notification_title.chaturmas_rejected',['sant' => $this->sant->name]); $extraNotificationData = []; $extraNotificationData['from_id'] = $this->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->user->id, $users)) { $users[$this->user->id] = $this->user->id; $this->storeNotification($notificationData); //Unread count increament unreadNotificationCounter($this->user->id); } } catch (\Exception $ex) { Log::error($ex); } } }