I want to send my user activation link through mail using Laravel Mailable. For sending mail .I did following way:
Mail::to($user['email'])->send(new RegisterEmail($user));
Where $user has the recently created user data.
And this is my RegisterEmail.php
class RegisterEmail extends Mailable
{
use Queueable, SerializesModels;
public $user;
public function __construct($user)
{
$this->user = $user;
}
public function build()
{
return $this->from('abc@gmail.com', 'ABC co')
->subject('PlugNThemes Activation Code ')
->view('emails.activation')
->with(['name' => $this->user->name])
->with('link',$this->user->link);
}
}
And here is the view part :
Welcome,
Please active your account :
But when the route called it's shows following Error on RegsiterEmail.php
Trying to get property of non-object
it couldn't get the $user
data. How do i send user data to view page using build()
method through RegisterEmail.php
?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire