I have a
receiveEmail boolean field in the User model of a Laravel application. How do I ensure that mail notifications respect this field, and only sends the email to the user if the field is true?
What I want is that this code:
$event = new SomeEvent($somedata); Auth::user()->notify($event);
or this one
where SomeEvent is a class that extends Notification and implements 'mail' on the via() method, only sends an email if the user has allowed emails.
You could also do the check in the event itself and pass user I’d to the event along with the somedata
Sign in to participate in this thread!