【发布时间】:2019-08-25 19:26:36
【问题描述】:
每次我调度作业时,ProcessJob::dispatch($model_object) 中传递的值在 ProcessJob 类的 handle() 方法中不可用
我尝试只传递模型记录的 id,但它在 ProcessJob 类的 handle() 中仍然不可用
public function __construct(int $id)
{
$this->id = $id;
$this->links = collect([]);
$this->phone_numbers = collect([]);
$this->emails = collect([]);
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
$columns = [];
logger($this->id);
}
我希望 logger($this->id) 记录 ID 号,但它没有。
id来自
ProcessJob::dispatch($crawler_job->id)->onQueue('crawler');
【问题讨论】:
-
您是否 100% 确信 $crawler_job->id 是一个 int?如果您只删除 (int $id) 中的 'int' 会发生什么
-
如果我运行 dispatchNow() 它会记录 ID 号。
-
让我再试一次。
-
我认为它有效。双重检查。