sant = $sant; $this->user = $user; $this->vihar = $vihar; } /** * Execute the job. * * @return void */ public function handle() { try { //Push Notification to followers of sant $followers = $this->sant->followers()->pluck('user_id'); $users = []; if (!empty($followers)) { foreach ($followers as $follower) { $tokens = UserDeviceToken::where('user_id', $follower) ->where('user_id', '!=', $this->user->id) ->get() ->toArray(); $pushData = []; if ($follower != $this->user->id) { if($tokens && $tokens > 0) { foreach ($tokens as $token) { $pushData['notId'] = $this->vihar->id ?? 1; $pushData['userToken'] = $token['token'] ?? []; $pushData['title'] = trans('notifications.notification_title.vihar_updated',['sant' => $this->sant->name]); $pushData['body'] = trans('notifications.push_sant.vihar_updated'); $pushData['image'] = ($this->user->avatar) ? $this->user->avatar : ""; $pushData['from_id'] = $this->sant->id; $extraData = []; $extraData['from_id'] = $this->sant->id; $extraData['user_id'] = $this->user->id ?? ''; $extraData['user_name'] = $this->user->name ?? ''; $extraData['user_type'] = 'sant'; $extraData['type'] = trans('notifications.sant_notification_type.vihar-updated'); $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 $notificationData = []; $notificationData['body'] = trans('notifications.sant.vihar_updated',['sant' => $this->sant->name]); $notificationData['user_id'] = $follower; $notificationData['type'] = trans('notifications.sant_notification_type.vihar-updated'); $notificationData['title'] = trans('notifications.notification_title.vihar_updated',['sant' => $this->sant->name]); $extraNotificationData = []; $extraNotificationData['from_id'] = $this->sant->id ?? ''; $extraNotificationData['user_id'] = $this->user->id ?? ''; $extraNotificationData['name'] = $this->user->name ?? ''; $extraNotificationData['avatar'] = ($this->user->avatar) ? $this->user->avatar : ""; $extraNotificationData['notification_type'] = Constant::STATUS_ONE; $extraNotificationData['user_type'] = 'sant'; $extraNotificationData['created_at'] = date('Y/m/d H:i:s'); $notificationData['extraNotificationData'] = $extraNotificationData ?? []; if (!in_array($follower, $users)) { $users[$follower] = $follower; $this->storeNotification($notificationData); //Unread count increament unreadNotificationCounter($follower); } } } } } catch (\Exception $ex) { Log::error($ex); } } }