Skip to content
This repository was archived by the owner on Jun 28, 2025. It is now read-only.

Commit 9924e47

Browse files
Merge pull request #8 from aloware/fix/clear-builder-orders
Fix clear builder orders
2 parents aacc878 + 49d6d78 commit 9924e47

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/CursorPaginationServiceProvider.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,11 @@ public function registerMacro()
6161
}
6262

6363
// Clear Default Quey Order By
64-
$this->query->orders = null;
64+
if($this instanceof EloquentBuilder) {
65+
$this->getQuery()->orders = null;
66+
} else {
67+
$this->orders = null;
68+
}
6569

6670
// If there's a sorting by the identifier, check if it's desc so the cursor is inverted
6771
$identifier_sort_inverted = $identifier_sort ? $identifier_sort['direction'] === 'desc' : false;

src/QueryBuilderHelper.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ public static function getCursorIdentifierColumn($builder)
4444
*/
4545
public static function getTableName($builder)
4646
{
47-
$table = explode(' ', trim($builder->from))[0];
47+
$from = str_replace('`', '', $builder->from);
48+
49+
$table = explode(' ', trim($from))[0];
4850

4951
return $table;
5052
}

0 commit comments

Comments
 (0)