Reputation: 3962
I'm developing a web site and would like to send a sms message to multiple phone numbers with Nexmo, using Laravel 5.4.
My application has a one-to-many relationship between a User
(Notifiable) and PhoneNumber
model. The latter has user_id
and number
fields.
I'd like to use the elegant Notifications system Laravel offers and just be able to send a message to ALL of a given user's phone numbers by doing $user->notify(new FooNotification())
.
I have tried routing the notification by adding a routeNotificationForNexmo
function to my User
model and returning the phone numbers as an array of strings, but as expected that returns an error ('array to string conversion').
Any ideas? Thanks in advance.
Edit: for now, I've made PhoneNumber implement Notifiable
as well, then I'll just have to invoke notify()
for each of a user's phone numbers... I'm still hoping for a better solution though.
Upvotes: 1
Views: 2287
Reputation: 56
Notifiable
trait to your PhoneNumber
model. (I see you've already done this)routeNotificationForNexmo
function to the PhoneNumber
model.Notification::send($user->numbers, new FooNotification)
Upvotes: 2