user = $user; $this->sant = $sant; $this->santMain = $santMain; } /** * 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_approved',['sant' => $this->santMain->name]); $pushData['body'] = trans('notifications.sant.sant_approved'); $pushData['image'] = ($this->user->avatar) ? $this->user->avatar : ""; $pushData['from_id'] = $this->user->id; $extraData = []; $extraData['user_id'] = $this->user->id ?? ''; $extraData['user_name'] = $this->user->name ?? ''; $extraData['type'] = trans('notifications.sant_notification_type.sant-approved'); $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 approved sant $notificationData = []; $notificationData['body'] = trans('notifications.sant.sant_approved'); $notificationData['user_id'] = $this->santMain->updated_by; $notificationData['type'] = trans('notifications.sant_notification_type.sant-approved'); $notificationData['title'] = trans('notifications.notification_title.sant_approved',['sant' => $this->santMain->name]); $extraNotificationData = []; $extraNotificationData['from_id'] = $this->santMain->id ?? ''; $extraNotificationData['user_id'] = $this->user->id ?? ''; $extraNotificationData['name'] = $this->santMain->name ?? ''; $extraNotificationData['avatar'] = ($this->santMain->avatar) ? $this->santMain->avatar : ""; $extraNotificationData['user_type'] = 'sant'; $extraNotificationData['created_at'] = date('Y/m/d H:i:s'); $notificationData['extraNotificationData'] = $extraNotificationData ?? []; if (!in_array($this->santMain->updated_by, $users)) { $users[$this->santMain->updated_by] = $this->santMain->updated_by; $this->storeNotification($notificationData); //Unread count increament unreadNotificationCounter($this->santMain->updated_by); } } catch (\Exception $ex) { Log::error($ex); } } }