2
Laravel keeps returning me as an undefined variable, for the $bloger variable. I’ve tried every way I know how, but the mistake persists. I already loaded the view through the controller and it worked perfectly, the problem is really in this class. Laravel 5.5
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
class Newsletter extends Mailable
{
use Queueable, SerializesModels;
public $request, $blog;
public function __construct($request, $blog)
{
$this->blog = $blog;
$this->request = $request;
}
public function build()
{
info($this->blog);
info($this->request);
$params = ['bloger'=>'blogar'];
return $this->view('email.newsletter')->with(['bloger'=>'blog']);
// return $this->view('email.newsletter')->with($params);
// return $this->view('email.newsletter', ['bloger'=>'blog']);
// return $this->view('email.newsletter', $params);
}
}
Apparently the problem is happening at the time you stop the class
Newsletter
, you are passing the 2 parameters?– Kayo Bruno
I decided to make the call directly from Controller, instead of by events and listeners.
– Glenys Mitchell
Yes, I was passing both parameter and checking by info();
– Glenys Mitchell