laravel-notification-channels / webpush

Webpush notifications channel for Laravel.
http://laravel-notification-channels.com
MIT License
681 stars 119 forks source link

How to use shorthand notation 'webpush' for the channel name in the via() method? #164

Open boryn opened 3 years ago

boryn commented 3 years ago

I'd like to return ['webpush'] in the via() method instead of WebPushChannel::class.

I based on https://medium.com/@sirajul.anik/laravel-notifications-part-2-creating-a-custom-notification-channel-6b0eb0d81294 and tried to register it in the AppServiceProvider.php with:

Notification::extend('webpush', function ($app) {
    return new WebPushChannel();
});

but WebPushChannel() constructor needs additional parameters and this method fails.

imrodrigoalves commented 1 year ago

Hello, Have you tried resolving the WebPushChannel from the container?

return $app->make(WebPushChannel::class);

Using this you delegate the responsability to the container.