I'm trying to send emails to the users who have been accepted by the admin using mailable api in Laravel 5.3.
class SurveyMail extends Mailable
{
use Queueable, SerializesModels;
public $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->view('mail.send')
->from('monsite@chezmoi.com');
}
and this is my controller
class EmailController extends Controller
{
public function send(Request $request,User $user)
{
Mail::to($user)
->send(new SurveyMail ($request->except('_token')));
}
}
the view:
<body style="background: black; color: white">
<h2>Prise de contact sur mon beau site</h2>
<p>Réception d'une prise de contact avec les éléments suivants :</p>
<ul>
<li><strong>Nom</strong> : {{ $user->name }}</li>
<li><strong>Email</strong> : {{ $user->email }}</li>
</body>
it seems that the argument User which is passed to the constructor is not accepted. Please, how can I fix this?