I can’t add constructor in my event listener.Laravel 11 there is no EventService provider also. I need an example for this
public function handle(NewUserEvent $event): void
{
Mail::send('3_Emails.1_CommonMailTemplate', $mailData, function ($message) use ($Name, $Email) {
$message->to($Email)
->subject("Contact | $Name")
->cc('[email protected]') // Add CC recipient
->bcc('[email protected]'); // Add BCC recipient
});
}
here i cant get $event in it.
2
Answers
Using the Event facade, you may manually register events and their corresponding listeners within the boot method of your application’s AppServiceProvider
It seems you have copied this part from somewhere. Before you come to this, there are a few things you need to do
NewUserEvent
In
AppEventsNewUserEvent.php
, if not, create oneIn Controller, call the event.
As I remember, Laravel 11 does not use
EventServiceProvider
; it is set to auto-discover event listeners. If not working, set it manually.