Make notifications cancellable

This commit makes certain notifications cancellable. This enables notifications to be sent conditionally based on the user's choice.
This commit is contained in:
2020-08-31 22:06:00 +01:00
parent 27b1f3170b
commit 17fb0e236f
8 changed files with 106 additions and 62 deletions

View File

@@ -8,10 +8,12 @@ use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
use App\Comment;
use App\Application;
use App\Traits\Cancellable;
use App\Facades\Options;
class NewComment extends Notification implements ShouldQueue
{
use Queueable;
use Queueable, Cancellable;
protected $application;
@@ -26,15 +28,9 @@ class NewComment extends Notification implements ShouldQueue
$this->application = $application;
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
public function optOut($notifiable)
{
return ['mail'];
return Options::getOption('notify_application_comment') !== 1;
}
/**