Skip to content

Commit 31b2790

Browse files
Merge pull request #16 from mabdullahsari/patch-1
Add custom creator alias to ChannelManager
2 parents 12d3da0 + 64daaf5 commit 31b2790

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,14 @@ Notice: The originator can contain a maximum of 11 alphanumeric characters.
6868
Now you can use the channel in your `via()` method inside the notification:
6969

7070
``` php
71-
use NotificationChannels\Cmsms\CmsmsChannel;
7271
use NotificationChannels\Cmsms\CmsmsMessage;
7372
use Illuminate\Notifications\Notification;
7473

7574
class VpsServerOrdered extends Notification
7675
{
7776
public function via($notifiable)
7877
{
79-
return [CmsmsChannel::class];
78+
return ['cmsms'];
8079
}
8180

8281
public function toCmsms($notifiable)

src/CmsmsServiceProvider.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55
namespace NotificationChannels\Cmsms;
66

77
use GuzzleHttp\Client as GuzzleClient;
8+
use Illuminate\Foundation\Application;
9+
use Illuminate\Notifications\ChannelManager;
810
use Illuminate\Support\ServiceProvider;
911
use NotificationChannels\Cmsms\Exceptions\InvalidConfiguration;
1012

1113
class CmsmsServiceProvider extends ServiceProvider
1214
{
13-
public function boot(): void
15+
public function register(): void
1416
{
1517
$this->app->when(CmsmsChannel::class)
1618
->needs(CmsmsClient::class)
@@ -21,5 +23,9 @@ public function boot(): void
2123

2224
return new CmsmsClient(new GuzzleClient(), $productToken);
2325
});
26+
27+
$this->app->afterResolving(ChannelManager::class, static function (ChannelManager $manager) {
28+
$manager->extend('cmsms', static fn (Application $app) => $app->make(CmsmsChannel::class));
29+
});
2430
}
2531
}

0 commit comments

Comments
 (0)