Skip to content

Commit

Permalink
if to() method is used to set the recipient phonenumber, then it has …
Browse files Browse the repository at this point in the history
…highest priority (#18)

* if to() method is used to set the recipient phonenumber, then it has the highest priority

* wip
  • Loading branch information
ossycodes authored May 6, 2022
1 parent 96e40b9 commit 4a9569c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,12 @@ It's important to know the Order in which the recipient phone number the notific
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)
3) Lastly if 1 and 2 are not set, then you can set the recipient phone number using ->to(19283281921)
3) Lastly if the recipient phone number is set using ->to(1111111), this will overide the phone number provided in either 1 or 2.
``` php
return (new AfricasTalkingMessage())
->content('Your SMS message content')
->to("put the recipient phonenumber here");
->to("put the recipient phonenumber here"); //eg ->to(11111111)
```
## Testing
Expand Down
6 changes: 5 additions & 1 deletion src/AfricasTalkingChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ public function send($notifiable, Notification $notification)
$message = $notification->toAfricasTalking($notifiable);

if (!$phoneNumber = $notifiable->routeNotificationFor('africasTalking')) {
$phoneNumber = $notifiable->phone_number ?? $message->getTo();
$phoneNumber = $notifiable->phone_number;
}

if(!empty($message->getTo())) {
$phoneNumber = $message->getTo();
}

if(empty($phoneNumber)) {
Expand Down

0 comments on commit 4a9569c

Please sign in to comment.