Laravel UNION ALL不能与where语句一起工作


Laravel UNION ALL not working with where statement

我想把两个队列合并成一个。

$buildings_queue=IngameBuildingQueue::where(DB::raw('UNIX_TIMESTAMP(`start_time` + `duration`)'),'<=',time());
$recruit_queue=IngameRecruitQueue::where(DB::raw('UNIX_TIMESTAMP(`start_time` + `duration`)'),'<=',time());
$queue=$buildings_queue->unionAll($recruit_queue);
dd($queue->toSql());

[ErrorException]未定义属性:Illuminate'Database'Eloquent'Builder::$bindings

但是当我删除where()方法时,一切都很好。

我该如何修复它?

根据Laravel用户手册,这应该可以工作

IngameRecruitQueue::where(DB::raw('UNIX_TIMESTAMP(`start_time` + `duration`)'),'<=',time())->union($buildings_queue)->get();

也试着用camelCase约定来写你的变量

美元buildings_queue 美元buildingsQueue

查看答案了解更多信息:https://softwareengineering.stackexchange.com/a/196463