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