0

guys, I create a panel with laravel 8 and create some emails jobs that must send emails to specific users on specific dates it works fine. I created the database with 2 columns user_id (id of the user that email sent to him/er) and type (type of emails such as Weekly, monthly, reset password, etc...) named Emails also. I added these lines to my EventserviceProvider that mentioned on the documents

'Illuminate\Mail\Events\MessageSent' => ['App\Listeners\LogSentMessage',],

then I defined these two on my email files (app/mail) these two data will pass to mailjob also then i can catch them on my handle function to use like this:

Mail::to($user->email)->send(new Firstweek($firstname,$user->id,'week1'));

to log these emails have been sent or not then if the email is sent this listener will run and save data to the database. till here all works fine.

I use the default reset password system of laravel that used notifications. my problem is when I request the reset password after sending the reset password email I face an error related to these requested logs that want to get user_id and type that needed for Email but I really do not have any idea how I can pass these data to notifications.

I really need your helps tank you so much.

1 Answers1

0

You can pass extra arguments to the Password reset event e.g new \Illuminate\Auth\Events\PasswordReset($user, $type_id) and attach a listener in your EventServiceProvider

Riliwan Balogun
  • 308
  • 1
  • 2
  • 10