WelcomeMail.php;
public function __construct(User $user)
{
$this->user = $user;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->view('email.register-mail');
}
}
RegisterController.php;
protected function create(array $data)
{
$user =User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => Hash::make($data['password']),
]);
$body = [];
$mailData = array('body'=>$body);
Mail::send('email.register-mail',$mailData, function ($message) use ($user){
$message->from(env('MAIL_USERNAME'), 'EksikParça.');
$message->subject('Hosgeldiniz!');
$message->to(new WelcomeMail($user));
});
return $user;
}
}
This is the code I wrote for the e-mail I send when the user registers. But I am getting an illegal offset type error. could be caused by why?
$message->to(...)
correctly .. its like you are trying to mix the old style of sending mail and the new mailable together – lagbox