Skip to content

Commit

Permalink
Add default sort
Browse files Browse the repository at this point in the history
  • Loading branch information
enjinabner committed Sep 6, 2023
1 parent c6fb621 commit 772b0d4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Models/Laravel/Traits/EagerLoadSelectFields.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ public static function loadBeams(
$with = [
$key => function ($query) use ($select, $args) {
$query->select(array_unique($select))
->when(Arr::get($args, 'after'), fn ($q) => $q->where('id', '>', Cursor::fromEncoded($args['after'])->parameter('id')));
->when($cursor = Cursor::fromEncoded(Arr::get($args, 'after')), fn ($q) => $q->where('id', '>', $cursor->parameter('id')))
->orderBy('beams.id');
// This must be done this way to load eager limit correctly.
if ($limit = Arr::get($args, 'first')) {
$query->limit($limit + 1);
Expand Down Expand Up @@ -139,7 +140,8 @@ public static function loadClaims(
$with = [
$key => function ($query) use ($select, $args) {
$query->select(array_unique($select))
->when(Arr::get($args, 'after'), fn ($q) => $q->where('id', '>', Cursor::fromEncoded($args['after'])->parameter('id')));
->when($cursor = Cursor::fromEncoded(Arr::get($args, 'after')), fn ($q) => $q->where('id', '>', $cursor->parameter('id')))
->orderBy('beam_claims.id');
// This must be done this way to load eager limit correctly.
if ($limit = Arr::get($args, 'first')) {
$query->limit($limit + 1);
Expand Down

0 comments on commit 772b0d4

Please sign in to comment.