0
我有一个Laravel 5.2应用程序,并使用作业来完成某些任务,我的问题是我想在另一个作业中创建作业。从另一个工作内部创建工作Laravel 5.2
这是我的代码:
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;
}
}
此代码创建的作业我的数据库(数据库驱动程序)内,但有效载荷不包含任何东西,它的值是0
$this->idCompany //this field is protected could this be the problem?
EDIT1
所以问题出现在$ matrixContacts var中,我已经更新了问题以显示下面的内容的一个例子。
[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"
}
你使用“DispatchesJobs”特性吗? https://laravel.com/docs/master/queues#pushing-jobs-onto-the-queue – herrjeh42
是的,我得到了这个 - >使用InteractsWithQueue,SerializesModels,DispatchesJobs; –
你的代码对我来说看起来很好 - 应该工作。如果你确实将“具体值”而不是变量传递给构造函数会发生什么?那样有用吗?如果您单独使用“importExcelInsert”作业,它是否可以正常工作?从控制器? – herrjeh42