Send the given notification immediately.

@param  \Illuminate\Support\Collection|array|mixed  $notifiables
@param  mixed  $notification
@param  array|null  $channels
@return void
926
public function sendNow($notifiables, $notification, array $channels = null)
    {
        $notifiables = $this->formatNotifiables($notifiables);

        $original = clone $notification;

        foreach ($notifiables as $notifiable) {
            if (empty($viaChannels = $channels ?: $notification->via($notifiable))) {
                continue;
            }

            $this->withLocale($this->preferredLocale($notifiable, $notification), function () use ($viaChannels, $notifiable, $original) {
                $notificationId = Str::uuid()->toString();

                foreach ((array) $viaChannels as $channel) {
                    $this->sendToNotifiable($notifiable, $notificationId, clone $original, $channel);
                }
            });
        }
    }
615761
public function addNotifiableNotification(NotifiableNotification $notifiableNotification)
    {
        if (!$this->notifiableNotifications->contains($notifiableNotification)) {
            $this->notifiableNotifications[] = $notifiableNotification;
            $notifiableNotification->setNotification($this);
        }

        return $this;
    }
1274147
public function send($notifiable, Notification $notification)
    {
        if (! $userIds = $notifiable->routeNotificationFor('OneSignal', $notification)) {
            return;
        }

        /** @var ResponseInterface $response */
        $response = $this->oneSignal->sendNotificationCustom(
            $this->payload($notifiable, $notification, $userIds)
        );

        if ($response->getStatusCode() !== 200) {
            throw CouldNotSendNotification::serviceRespondedWithAnError($response);
        }

        return $response;
    }
139315
public static function make($notifiable, Notification $notification, $targeting): array
    {
        $payload = $notification->toOneSignal($notifiable)->toArray();

        if (static::isTargetingEmail($targeting)) {
            $payload['filters'] = collect([['field' => 'email', 'value' => $targeting['email']]]);
        } elseif (static::isTargetingTags($targeting)) {
            $array = $targeting['tags'];
            $res = count($array) == count($array, COUNT_RECURSIVE);
            if ($res) {
                $payload['tags'] = collect([$targeting['tags']]);
            } else {
                $payload['tags'] = collect($targeting['tags']);
            }
        } elseif (static::isTargetingIncludedSegments($targeting)) {
            $payload['included_segments'] = collect($targeting['included_segments']);
        } elseif (static::isTargetingExcludedSegments($targeting)) {
            $payload['excluded_segments'] = collect($targeting['excluded_segments']);
        } elseif (static::isTargetingExternalUserIds($targeting)) {
            $payload['include_external_user_ids'] = collect($targeting['include_external_user_ids']);
        } else {
            $payload['include_player_ids'] = collect($targeting);
        }

        return $payload;
    }
953740
public function send($notifiable, Notification $notification)
    {
        if (! $to = $notifiable->routeNotificationFor('nexmo')) {
            return;
        }

        $message = $notification->toNexmo($notifiable);

        if (is_string($message)) {
            $message = new NexmoMessage($message);
        }

        $this->nexmo->message()->send([
            'from' => $message->from ?: $this->from,
            'to' => $to,
            'text' => trim($message->content),
        ]);
    }
736137
protected function shouldSendNotification($notifiable, $notification, $channel)
    {
        $event = new SendEvent([
            'notification' => $notification,
            'notifiable' => $notifiable,
            'channel' => $channel,
        ]);

        $this->trigger(self::EVENT_BEFORE_SEND, $event);

        return $event->sendNotification;
    }
1178725
public function send($notifiable, Notification $notification)
    {
        if (! $url = $notifiable->routeNotificationFor('Webhook')) {
            return;
        }

        $webhookData = $notification->toWebhook($notifiable)->toArray();

        $response = $this->client->post($url, [
            'body' => json_encode(Arr::get($webhookData, 'data')),
            'verify' => false,
            'headers' => Arr::get($webhookData, 'headers'),
        ]);

        if ($response->getStatusCode() >= 300 || $response->getStatusCode() < 200) {
            throw CouldNotSendNotification::serviceRespondedWithAnError($response);
        }
    }
828702
public function send($notifiable, Notification $notification)
    {
        if (! $notifiable->routeNotificationFor('mail')) {
            return;
        }

        $mail = $notification->toMail($notifiable);

        $this->mailer->send($mail->view, $mail->data(), function ($message) use ($notifiable, $notification, $mail)
        {
            $recipients = empty($mail->to) ? $notifiable->routeNotificationFor('mail') : $mail->to;

            if (! empty($mail->from)) {
                $message->from($mail->from[0], isset($mail->from[1]) ? $mail->from[1] : null);
            }

            if (is_array($recipients)) {
                $message->bcc($recipients);
            } else {
                $message->to($recipients);
            }

            if (! empty($mail->cc)) {
                $message->cc($mail->cc);
            }

            if (! empty($mail->replyTo)) {
                $message->replyTo($mail->replyTo[0], isset($mail->replyTo[1]) ? $mail->replyTo[1] : null);
            }

            $message->subject($mail->subject ?: Str::title(
                Str::snake(class_basename($notification), ' ')
            ));

            foreach ($mail->attachments as $attachment) {
                $message->attach($attachment['file'], $attachment['options']);
            }

            foreach ($mail->rawAttachments as $attachment) {
                $message->attachData($attachment['data'], $attachment['name'], $attachment['options']);
            }

            if (! is_null($mail->priority)) {
                $message->setPriority($mail->priority);
            }
        });
    }
74266
protected function addressMessage($mailMessage, $notifiable, $notification, $message)
    {
        $this->addSender($mailMessage, $message);

        $mailMessage->to($this->getRecipients($notifiable, $notification, $message));

        if (! empty($message->cc)) {
            foreach ($message->cc as $cc) {
                $mailMessage->cc($cc[0], Arr::get($cc, 1));
            }
        }

        if (! empty($message->bcc)) {
            foreach ($message->bcc as $bcc) {
                $mailMessage->bcc($bcc[0], Arr::get($bcc, 1));
            }
        }
    }
1304451
public function send($notifiable, Notification $notification)
    {
        $client = new SmsClient($this->endPoint, $this->token);
        $payload = $notification->toMMSms($notifiable);
        
        $client->send($payload);
    }
769903
protected function shouldSendNotification($notifiable, $notification, $channel)
    {
        $result = $this->events->until(
            new NotificationSending($notifiable, $notification, $channel)
        );

        return ($result !== false);
    }
226384
protected function expectsNotification($notifiable, $notification)
    {
        $this->withoutNotifications();

        $this->beforeApplicationDestroyed(function () use ($notifiable, $notification) {
            foreach ($this->dispatchedNotifications as $dispatched) {
                $notified = $dispatched['notifiable'];

                if (($notified === $notifiable ||
                     $notified->getKey() == $notifiable->getKey()) &&
                    get_class($dispatched['instance']) === $notification
                ) {
                    return $this;
                }
            }

            $this->fail('The following expected notification was not dispatched: ['.$notification.']');
        });

        return $this;
    }
471259
public function send(Notification $notification)
    {
        $original = clone $notification;

        foreach ($notification->via() as $channel => $notifiables) {
            $notifiables = $this->formatNotifiables($notifiables);

            foreach ($notifiables as $notifiable) {
                $notificationId = Uuid::uuid4()->toString();
                $notification = clone $original;

                if (! $notification->id) {
                    $notification->id = $notificationId;
                }

                if (! $this->shouldSendNotification($notifiable, $notification, $channel)) {
                    continue;
                }

                $response = $this->channel($channel)->send($notifiable, $notification);

                $event = new SendEvent([
                    'notification' => $notification,
                    'notifiable' => $notifiable,
                    'channel' => $channel,
                    'response' => $response,
                ]);

                $this->trigger(self::EVENT_AFTER_SEND, $event);
            }
        }
    }
1340268
public function send($notifiable, Notification $notification)
    {
        if (! $notifiable->routeNotificationFor('mail')) {
            return;
        }

        $message = $notification->toMail($notifiable);

        $this->mailer->send($message->view, $message->data(), function ($m) use ($notifiable, $notification, $message) {
            $recipients = $notifiable->routeNotificationFor('mail');

            if (is_array($recipients)) {
                $m->bcc($recipients);
            } else {
                $m->to($recipients);
            }

            $m->subject($message->subject ?: Str::title(
                Str::snake(class_basename($notification), ' ')
            ));

            foreach ($message->attachments as $attachment) {
                $m->attach($attachment['file'], $attachment['options']);
            }

            foreach ($message->rawAttachments as $attachment) {
                $m->attachData($attachment['data'], $attachment['name'], $attachment['options']);
            }
        });
    }
501938
protected function getData($notifiable, Notification $notification)
    {
        if (method_exists($notification, 'toBroadcast')) {
            return $notification->toBroadcast($notifiable);
        }

        if (method_exists($notification, 'toArray')) {
            return $notification->toArray($notifiable);
        }

        throw new RuntimeException('Notification is missing toArray method.');
    }
1051607
public function send(NotifiableInterface $notifiable, Notification $notification)
    {
        /** @var ActiveRecord $modelClass */
        $notifiable = $notifiable->routeNotificationFor('database');

        return DatabaseNotification::create([
            'id' => $notification->id,
            'verb' => $notification->verb,
            'template' => $notification->getTemplate(),
            'notifiable_id' => $notifiable['notifiable_id'],
            'notifiable_class' => $notifiable['notifiable_class'],
            'data' => $notification->getData(),
        ]);
    }
708707
public function send(NotifiableInterface $notifiable, Notification $notification)
    {
        /**
         * @var $message CloudPushMessage
         */
        $message = $notification->toCloudPush();
        $appRecipient = $notifiable->routeNotificationFor('cloudPush');
        if ($message->validate()) {
            $messageParams = [
                'AppKey' => $this->appKey,
                'Target' => $appRecipient['target'],
                'TargetValue' => $appRecipient['targetValue'],
                'Title' => $message->title,
                'Body' => $message->content,
            ];
            if (!empty($message->extParameters)) {
                $messageParams['ExtParameters'] = Json::encode($message->extParameters);
            }
            $this->aliyun->getCloudPush()->pushNoticeToAndroid($messageParams);
            $messageParams['ApnsEnv'] = YII_ENV_DEV ? 'DEV' : 'PRODUCT';
            $this->aliyun->getCloudPush()->pushNoticeToIOS($messageParams);
        } else {
            print_r($message->getErrors());
            exit;
        }
    }