generated from spatie/package-skeleton-laravel
-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Description
See https://laravel.com/docs/11.x/notifications#on-demand-notifications
Under the hood, on demand notifications set the notifiable as AnonymousNotifiable, which have access to $this->routes['your-channel'].
We need to update the Twilio logic when sending a message (see code) to handle on demand notifications. Something potentially like:
private function getRecipientPhoneNumber(mixed $notifiable): string
{
if ($notifiable instanceof AnonymousNotification && array_key_exists('twilio', $notifiable->routes)) {
return strval($notifiable->routes['twilio']);
}
if ($notifiable->twilioPhoneNumberField !== null) {
return $notifiable->twilioPhoneNumberField;
}
return $notifiable->phone_number;
}
.
.
.
// Send the SMS message
$this->client->messages->create(
$this->getRecipientPhoneNumber()
[
'from' => $this->from_phone_number,
'body' => $twilioMessage->fullMessage(),
]
);Then update the readme with:
- On-Demand notification example
- Set the $twilioPhoneNumberField to a string
Metadata
Metadata
Assignees
Labels
No labels