You could create two separate mail classes and call them from your controller when the user is created. Build your logic in the controller.
Sep 7, 2020
2
Level 13
Verification email only if role is "student" - manually verify if role is "teacher"
Hi there π
I have the roles "student" and "teacher" in my app and only want to send a verification email if a new user selected the role "student". If the new user selected "teacher" I would like the user to be verified by an admin and send a different email after the registration.
Has anyone an idea how I could implement that?
So far I defined a custom verification email in my AppServiceProvider like this:
public function boot()
{
...
// Custom email for verification
VerifyEmail::toMailUsing(function ($notifiable, $verifyUrl) {
$mail = new MailMessage;
$mail->subject('Welcome to PriMa! - Please verify your email address');
$mail->markdown('emails.verify-email', ['url' => $verifyUrl]);
return $mail;
});
...
}
Works fine for all users but I have the feeling, that I am wrong in the boot function within the AppServiceProvider to accomplish my goal.
Thank you for helping π
Level 21
Please or to participate in this conversation.