Last active
February 17, 2018 23:34
-
-
Save hotmeteor/adb304ca46df6bc70df273942fee2945 to your computer and use it in GitHub Desktop.
Handling delayed notifications in Laravel, pt. 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Base\Providers; | |
use App\Notifications\Listeners\NotificationSendingListener; | |
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider; | |
use Illuminate\Notifications\Events\NotificationSending; | |
class EventServiceProvider extends ServiceProvider | |
{ | |
protected $listen = [ | |
NotificationSending::class => [ | |
NotificationSendingListener::class, | |
], | |
]; | |
public function boot() | |
{ | |
parent::boot(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Notifications\Listeners; | |
use Illuminate\Notifications\Events\NotificationSending; | |
class NotificationSendingListener | |
{ | |
public function handle(NotificationSending $event) | |
{ | |
if (method_exists($event->notification, 'dontSend')) { | |
return !$event->notification->dontSend($event->notifiable); | |
} | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment