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
Notification::send($users, $event);
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.
If auth user receiveEmail ?
if(Auth::user()->recieveEmail{
Auth::user()-notify($event);
}
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!
The Laravel portal for problem solving, knowledge sharing and community building.
The community