Skip to content

Commit 4a9569c

Browse files
authored
if to() method is used to set the recipient phonenumber, then it has highest priority (#18)
* if to() method is used to set the recipient phonenumber, then it has the highest priority * wip
1 parent 96e40b9 commit 4a9569c

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,12 @@ It's important to know the Order in which the recipient phone number the notific
144144
145145
2) if you did not define routeNotificationForAfricasTalking() method on the Notifiable class (User.php in this case), then the phone_number attribute of the User will be used ($user->phone_number)
146146
147-
3) Lastly if 1 and 2 are not set, then you can set the recipient phone number using ->to(19283281921)
147+
3) Lastly if the recipient phone number is set using ->to(1111111), this will overide the phone number provided in either 1 or 2.
148148
149149
``` php
150150
return (new AfricasTalkingMessage())
151151
->content('Your SMS message content')
152-
->to("put the recipient phonenumber here");
152+
->to("put the recipient phonenumber here"); //eg ->to(11111111)
153153
```
154154
155155
## Testing

src/AfricasTalkingChannel.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ public function send($notifiable, Notification $notification)
3131
$message = $notification->toAfricasTalking($notifiable);
3232

3333
if (!$phoneNumber = $notifiable->routeNotificationFor('africasTalking')) {
34-
$phoneNumber = $notifiable->phone_number ?? $message->getTo();
34+
$phoneNumber = $notifiable->phone_number;
35+
}
36+
37+
if(!empty($message->getTo())) {
38+
$phoneNumber = $message->getTo();
3539
}
3640

3741
if(empty($phoneNumber)) {

0 commit comments

Comments
 (0)