Diogo Silva
Diogo Silva

Reputation: 39

Create job from inside another job Laravel 5.2

I have a Laravel 5.2 application and im using jobs to do certain tasks, my problem is that i want to create jobs inside another job.

This is my code:

public function handle(){


if ($rowMatrix == 500) {
                $job = (new importExcelInsert($matrixContacts, $matrixDefaultFields, $matrixCustomFields, $this->idCompany))->delay($jobDelay)->onQueue('excelInserts');
                $this->dispatch($job);
                $this->insertIntoTJobsUserExcel($this->idCompany, $this->idList, $this->contactListState);
                $matrixContacts = [];
                $matrixDefaultFields = [];
                $matrixCustomFields = [];
                $rowMatrix = 0;
            }


 }

This code creates the jobs inside my database (Database driver) but the payload doesn't contain anything ,its value is 0.

$this->idCompany //this field is protected could this be the problem?

EDIT1

So the problem resides in the $matrixContacts var , i've updated the question to show an example of the contents below.

 [3524]=>
  array(5) {
    [0]=>
    object(Webpatser\Uuid\Uuid)#225258 (8) {
      ["bytes":protected]=>
      string(16) "µ╬╩÷OEèe║³An┬¥"
      ["hex":protected]=>
      NULL
      ["string":protected]=>
      string(36) "e6ceca1e-f64f-4512-8a65-bafc416ec2be"
      ["urn":protected]=>
      NULL
      ["version":protected]=>
      NULL
      ["variant":protected]=>
      NULL
      ["node":protected]=>
      NULL
      ["time":protected]=>
      NULL
    }
    [1]=>
    string(1) "1"
    [2]=>
    string(9) "Importado"
    [3]=>
    string(34) "email"
    [4]=>
    string(30) "nC0rI7eaH3TCWlq4tqRTJuNjp1mvew"
  }

Upvotes: 0

Views: 1307

Answers (1)

herrjeh42
herrjeh42

Reputation: 2793

Your code looks ok to me. Try to simplify the parameters, maybe there is a problem with the serializer (i.e. bug).

Upvotes: 1

Related Questions