Skip to content

Commit 0567794

Browse files
committed
feat: improve logic
1 parent 464af94 commit 0567794

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

src/Eloquent/Builder.php

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -234,20 +234,11 @@ protected function ensureOrderForCursorPagination($shouldReverse = false)
234234
})->toArray();
235235
}
236236

237-
return $this->mapMongodbOrdersToEloquentOrders($this->query->orders);
238-
}
239-
240-
private function mapMongodbOrdersToEloquentOrders($orders)
241-
{
242-
$eloquentOrders = [];
243-
244-
foreach ($orders as $column => $direction) {
245-
$eloquentOrders[] = [
237+
return collect($this->query->orders)->map(function ($direction, $column) {
238+
return [
246239
'column' => $column,
247240
'direction' => $direction === 1 ? 'asc' : 'desc',
248241
];
249-
}
250-
251-
return collect($eloquentOrders);
242+
})->values();
252243
}
253244
}

0 commit comments

Comments
 (0)