Skip to content

Commit 37a859f

Browse files
committed
Add enabled config
1 parent e1aef8b commit 37a859f

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

config/twilio-notification-channel.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22

33
return [
4+
'enabled' => env('TWILIO_ENABLED', true),
45
'username' => env('TWILIO_USERNAME'), // optional when using auth token
56
'password' => env('TWILIO_PASSWORD'), // optional when using auth token
67
'auth_token' => env('TWILIO_AUTH_TOKEN'), // optional when using username and password

src/TwilioChannel.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ public function __construct(Twilio $twilio, Dispatcher $events)
4343
*/
4444
public function send($notifiable, Notification $notification)
4545
{
46+
if (! $this->twilio->config->enabled()) {
47+
return;
48+
}
49+
4650
try {
4751
$to = $this->getTo($notifiable, $notification);
4852
$message = $notification->toTwilio($notifiable);

src/TwilioConfig.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ public function __construct(array $config)
1515
$this->config = $config;
1616
}
1717

18+
public function enabled()
19+
{
20+
return $this->config['enabled'];
21+
}
22+
1823
public function usingUsernamePasswordAuth(): bool
1924
{
2025
return $this->getUsername() !== null && $this->getPassword() !== null && $this->getAccountSid() !== null;

0 commit comments

Comments
 (0)