我希望将两个队列合二为一。
$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());
Laravel throw:
[ErrorException]未定义的属性:Illuminate \ Database \ Eloquent \ Builder :: $ bindings
但是当我删除where()
方法时,一切正常。
我该如何解决?
答案 0 :(得分:0)
根据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