1 | <?php |
||
2 | |||
3 | namespace Fouladgar\MobileVerification\Notifications\Channels; |
||
4 | |||
5 | use Fouladgar\MobileVerification\Contracts\SMSClient; |
||
6 | use Fouladgar\MobileVerification\Notifications\Messages\MobileVerificationMessage; |
||
7 | use Illuminate\Notifications\Notification; |
||
8 | |||
9 | class VerificationChannel |
||
10 | { |
||
11 | /** |
||
12 | * SMSClient (i.e. Nexmo). |
||
13 | * |
||
14 | * @var SMSClient |
||
15 | */ |
||
16 | protected $SMSClient; |
||
17 | |||
18 | /** |
||
19 | * VerificationChannel constructor. |
||
20 | * |
||
21 | * @param SMSClient $SMSClient |
||
22 | */ |
||
23 | public function __construct(SMSClient $SMSClient) |
||
24 | { |
||
25 | $this->SMSClient = $SMSClient; |
||
26 | } |
||
27 | |||
28 | /** |
||
29 | * Send the given notification. |
||
30 | * |
||
31 | * @param $notifiable |
||
32 | * @param Notification $notification |
||
33 | * |
||
34 | * @return mixed|void |
||
35 | */ |
||
36 | public function send($notifiable, Notification $notification) |
||
37 | { |
||
38 | if (! $notifiable->routeNotificationFor('verification_mobile', $notification)) { |
||
39 | return; |
||
40 | } |
||
41 | |||
42 | /** @var MobileVerificationMessage $message */ |
||
43 | $message = $notification->toMobile($notifiable); |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
44 | |||
45 | return $this->SMSClient->sendMessage($message->getPayload()); |
||
46 | } |
||
47 | } |
||
48 |