user = $user; $this->allUsers = $allUsers; } /** * Execute the job. * * @return void */ public function handle() { try { //Push Notification to all users if (!empty($this->allUsers)) { foreach ($this->allUsers as $userId) { $tokens = UserDeviceToken::where('user_id', $userId) ->get() ->toArray(); $pushData = []; $users = []; if ($userId != $this->user->id) { if($tokens && $tokens > 0) { foreach ($tokens as $token) { $pushData['userToken'] = $token['token'] ?? []; $pushData['title'] = trans('notifications.notification_title.new_sign_up',['user' => $this->user->name]); $pushData['body'] = trans('notifications.push_register.new_sign_up'); $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['user_type'] = 'shravak'; $extraData['type'] = trans('notifications.register_type.new-sign-up'); $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.register.new_sign_up',['user' => $this->user->name]); $notificationData['user_id'] = $userId; $notificationData['type'] = trans('notifications.register_type.new-sign-up'); $notificationData['title'] = trans('notifications.notification_title.new_sign_up',['user' => $this->user->name]); $extraNotificationData = []; $extraNotificationData['from_id'] = $this->user->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'] = 'shravak'; $extraNotificationData['created_at'] = date('Y/m/d H:i:s'); $notificationData['extraNotificationData'] = $extraNotificationData ?? []; if (!in_array($userId, $users)) { $users[$userId] = $userId; $this->storeNotification($notificationData); //Unread count increament unreadNotificationCounter($userId); } } } } } catch (\Exception $ex) { Log::error($ex); } } }