i have to update from 5.1 to 5.4
this was code for mail with 5.1
Mail::queue('emails.welcome_client', compact('user', 'userPassword'), function ($message) use ($user, $adminEmails) {
$message->subject('Welcome to Enterprise Solutions!');
$message->from(env('MAIL_FROM_ADDRESS'), env('MAIL_FROM_NAME'));
$message->to($user->email);
foreach($adminEmails as $adminEmail) {
$message->bcc($adminEmail);
}
});
I have to change from laravel 5.1 to 5.4 so i create object mail
here it is
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
class ClientMail extends Mailable
{
use Queueable, SerializesModels;
/**
* Create a new message instance.
*
* @return void
*/
public $user;
// protected $content;
public function __construct($user)
{
$this->content = $user;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->from(('MAIL_FROM_ADDRESS'), env('MAIL_FROM_NAME'))
->subject('Welcome to Enterprise Solutions!')
->view('emails.welcome_client');
}
}
and in controller i do this
Mail::to($user->email)
->bcc($adminEmail)
->queue(new ClientMail($adminEmails));
}
when I try to run I get this error Undefined $adminEmail How I can fix this problem ?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire