I’m facing the following error in the failed_jobs
database table:
ErrorException: Undefined property: stdClass::$subscription in /home/sm/public_html/app/Mail/NewCustomer.php:45
This is pretty basic. It means the property $subscription
does not exists, but…the problem is that I don’t call $subscription
anywhere in the class code.
In the controller I assign the values:
$to = ['email' => 'someemail@gmail.com', 'name' => 'Name test'];
$mail = new stdClass;
$mail->to = $to;
$mail->subject = 'Subject test';
$mail->body = 'Body test';
Mail::queue(new AppMailNewCustomer($mail));
And the NewCustomer class contains:
namespace AppMail;
use IlluminateBusQueueable;
use IlluminateContractsQueueShouldQueue;
use IlluminateMailMailable;
use IlluminateQueueSerializesModels;
class NewCustomer extends Mailable
{
use Queueable, SerializesModels;
/**
* Holds the item content
*
* @var Array
*/
protected $item;
/**
* Create a new message instance.
*
* @param Array
*
* @return void
*/
public function __construct($item)
{
$this->item = $item;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
$this->to($this->item->to['email'], $this->item->to['name'])
->subject($this->item->subject)
->view('mails/new_customer')
->with('item', $this->item);
return $this;
}
}
The view mails/new_customer
also does not contain anything related with $subscription
.
Is this some cache problem or something? I can’t figure out where the variable $subscription
comes from.
If instead of Queue I send the email immediately, it works great:
Mail::send(new AppMailNewCustomer($mail));
Advertisement
Answer
Solved.
It was indeed a cache problem. Run php artisan queue:restart
in terminal or through laravel:
Artisan::call('queue:restart');