Unable to return no phones from routeNotificationForSmscru
Closed this issue · 1 comments
If I return null
, an empty string or an empty array from the routeNotificationForSmscru
method of a Notifiable, I get a CouldNotSendNotification
exception. I think this is incorrect because all the built-in Laravel channels just do nothing if no recipient is set (examples: 1, 2, 3).
To workaround it I have to do the following in my notification classes:
public function via($notifiable)
{
if ($notifiable->routeNotificationFor('smscru', $this)) {
return [SmscRuChannel::class];
} else {
return [];
}
}
There is one more problem. Notifications objects are not passed to the routeNotificationForSmscru
method so I can't decide what number to send an SMS to depending on the notification class or object.
Also it would be great if I can return either a string or an array of phone numbers from routeNotificationForSmscru
method. I know I can return multiple phones in a single string separating them by comma, but the array would be a more convenient and Laravel-style way.
If you agree, I can implement all the features and make a pull request.
Thanks. I agree and I'm waiting for a PR.