Skip to content

Commit 94248f8

Browse files
committed
Added a way to get query without orderBy score call
1 parent 0e2527c commit 94248f8

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/SearchBuilder.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,15 @@ public function get(): Collection
8383
* Build and get the search query
8484
*/
8585
public function getQuery(): EloquentBuilder
86+
{
87+
return $this->getQueryWithoutOrderBy()
88+
->orderBy('score', 'desc');
89+
}
90+
91+
/**
92+
* Build and get the search query
93+
*/
94+
public function getQueryWithoutOrderBy(): EloquentBuilder
8695
{
8796
if (is_null($this->query)) {
8897
$this->setQuery($this->model->query());
@@ -92,8 +101,7 @@ public function getQuery(): EloquentBuilder
92101

93102
return $this->query
94103
->withExpression('id_and_total_score', $this->getScoreQuery())
95-
->join('id_and_total_score', $table.'.id', 'id_and_total_score.id')
96-
->orderBy('score', 'desc');
104+
->join('id_and_total_score', $table.'.id', 'id_and_total_score.id');
97105
}
98106

99107
/**

0 commit comments

Comments
 (0)