Skip to content

Instantly share code, notes, and snippets.

@hotmeteor
Last active February 17, 2018 23:34
Show Gist options
  • Save hotmeteor/adb304ca46df6bc70df273942fee2945 to your computer and use it in GitHub Desktop.
Save hotmeteor/adb304ca46df6bc70df273942fee2945 to your computer and use it in GitHub Desktop.
Handling delayed notifications in Laravel, pt. 3
<?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();
}
}
<?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