3

I want to get two queues into one.

$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] Undefined property: Illuminate\Database\Eloquent\Builder::$bindings

but when I delete where() methods everything works fine.

How can I fix it?

bcesars
  • 1,016
  • 1
  • 17
  • 36

1 Answers1

0

According to the Laravel user manual this should work

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

Also try to write your variables in camelCase convention

$buildings_queue will be $buildingsQueue

check this answer to learn more: https://softwareengineering.stackexchange.com/a/196463

Community
  • 1
  • 1
0x1ad2
  • 8,014
  • 9
  • 35
  • 48