From 57fb2d3551d0016aeac1b5bfd33884b243c7a947 Mon Sep 17 00:00:00 2001 From: Antonio Carlos Ribeiro Date: Mon, 1 Jul 2024 23:58:04 +0200 Subject: [PATCH] Get the key name through getScoutKeyName() like all other engines --- src/Engines/DatabaseEngine.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Engines/DatabaseEngine.php b/src/Engines/DatabaseEngine.php index 99813728..f5d6e136 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->getKeyName(), 'desc'); + $query->orderBy($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->getKeyName(), 'desc'); + $query->orderBy($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->getKeyName(), 'desc'); + $query->orderBy($builder->model->getScoutKeyName(), 'desc'); }) ->get(); } @@ -198,7 +198,7 @@ protected function initializeSearchQuery(Builder $builder, array $columns, array $canSearchPrimaryKey = ctype_digit($builder->query) && in_array($builder->model->getKeyType(), ['int', 'integer']) && ($connectionType != 'pgsql' || $builder->query <= PHP_INT_MAX) && - in_array($builder->model->getKeyName(), $columns); + in_array($builder->model->getScoutKeyName(), $columns); if ($canSearchPrimaryKey) { $query->orWhere($builder->model->getQualifiedKeyName(), $builder->query); @@ -214,7 +214,7 @@ protected function initializeSearchQuery(Builder $builder, array $columns, array $this->getFullTextOptions($builder) ); } else { - if ($canSearchPrimaryKey && $column === $builder->model->getKeyName()) { + if ($canSearchPrimaryKey && $column === $builder->model->getScoutKeyName()) { continue; }