I was try to make some email to send email acticvation code when someone register. so i make it an event called UserRegistered. On the UserRegistered i pass the user data like this:
public $user;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct(User $user)
{
$this->user = $user;
}
and here's my listener:
public function handle(UserRegistered $event)
{
Mail::to($event->user)->send(new SendActivationCode($event));
}
and here the SendActivatiionCode class:
protected $user;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct(User $user)
{
$this->user = $user;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->markdown('mails.user.activation')->with([
'name' => $this->user->name,
'token' => $this->user->token,
]);
}
but i got this errors:
"Type error: Argument 1 passed to Illuminate\Mail\PendingMail::send() must be an instance of Illuminate\Mail\Mailable, instance of App\Listeners\SendActivationCode given, called in E:\laragon\www\blog\app\Listeners\SendActivationCode.php on line 30 ◀"
so what can make me get this errors and how to fix it? thanks.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire