PHP Mail class does not load variables in the View

Asked

Viewed 31 times

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?

  • I decided to make the call directly from Controller, instead of by events and listeners.

  • Yes, I was passing both parameter and checking by info();

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.