尽管文档另有声明,但在 Laravel 中尝试在 Job 类中设置连接名称可能会失败并显示错误:[Job Class] and Illuminate\Bus\Queueable define the same property ($connection) in the composition of [Job Class]. However, the definition differs and is considered incompatible. Class was composed
1 回答
红糖糍粑
TA贡献1815条经验 获得超6个赞
我相信这是 PHP 7.3 和 Laravel 5.8 之间的兼容性问题。引发错误是因为 Queueable trait 已经定义了 'connection' 类变量。
要修复错误,我们只需要设置变量而不是声明它。
破碎作业类:
class UpdateProductInventory implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public $connection = 'database';
}
固定作业类:
class UpdateProductInventory implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
protected $product;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct()
{
$this->connection = 'database';
}
}
- 1 回答
- 0 关注
- 353 浏览
添加回答
举报
0/150
提交
取消