This is most likely not a fault of the Laravel Queue system. Instead, this error is thrown by PHP when an array is to be accessed by an unknown/unset element.
"Notice: Undefined variable", "Notice: Undefined index", and "Notice: Undefined offset" using PHP
For example:
// Initialise an empty array
$myArray = [];
// Attempt to access an element that hasn't been set yet
echo $myArray['breadCake'];
In your case, have a look through your code that deals with queueing and search for ['table'], ["table"] or anything that would need a "table" set.
It may be handy to anyone reading this and considering using Laravel Queues to remember a few things:
Queues are asynchronous and do not have access to the variables you once set in the application unless you pass them into something queue-able.
In Laravel 5, capture all the data you require for a job to exist in the Event __construct()
method. Events have access to a trait called SerializesModels
. You can pass your models as instances (with attributes) to the __construct()
method (such as __construct(User $user)
. Assign your variables to the Event class scope (for example: $this->user = $user
). This is passed to the EventListener
handle(Event $event)
method. This is called when the queue is being processed. The __construct()
should be blank (or filled in with repositories / services / other handy bits and pieces).
You can access the objects passed to the handle(Event $event) method:
public function handle(MyEvent $myEvent)
{
$this->user = $myEvent->user;
$mailData = ['user'=>$this->user];
Mail::queue('viewdir.view',$mailData, function($message) use ($mailData) {
$message->to($mailData['user']->email);
// other stuff
});
}
I hope this helps anyone reading.