From a17af146f52d875571ad7606878c8272ad4aa74c Mon Sep 17 00:00:00 2001 From: Friso Modderman Date: Tue, 26 Nov 2024 15:37:50 +0100 Subject: [PATCH] Fix: ambigious queries when adding other tables to the query builder (#887) Co-authored-by: Friso Modderman --- src/Engines/DatabaseEngine.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Engines/DatabaseEngine.php b/src/Engines/DatabaseEngine.php index f5d6e136..e40db1e0 100644 --- a/src/Engines/DatabaseEngine.php +++ b/src/Engines/DatabaseEngine.php @@ -92,7 +92,7 @@ public function paginateUsingDatabase(Builder $builder, $perPage, $pageName, $pa } }) ->when(! $this->getFullTextColumns($builder), function ($query) use ($builder) { - $query->orderBy($builder->model->getScoutKeyName(), 'desc'); + $query->orderBy($builder->model->getTable().'.'.$builder->model->getScoutKeyName(), 'desc'); }) ->paginate($perPage, ['*'], $pageName, $page); } @@ -127,7 +127,7 @@ public function simplePaginateUsingDatabase(Builder $builder, $perPage, $pageNam } }) ->when(! $this->getFullTextColumns($builder), function ($query) use ($builder) { - $query->orderBy($builder->model->getScoutKeyName(), 'desc'); + $query->orderBy($builder->model->getTable().'.'.$builder->model->getScoutKeyName(), 'desc'); }) ->simplePaginate($perPage, ['*'], $pageName, $page); } @@ -152,7 +152,7 @@ protected function searchModels(Builder $builder, $page = null, $perPage = null) } }) ->when(! $this->getFullTextColumns($builder), function ($query) use ($builder) { - $query->orderBy($builder->model->getScoutKeyName(), 'desc'); + $query->orderBy($builder->model->getTable().'.'.$builder->model->getScoutKeyName(), 'desc'); }) ->get(); }