Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relationship result sorting #4858

Merged
merged 7 commits into from
Apr 7, 2020
Merged

Relationship result sorting #4858

merged 7 commits into from
Apr 7, 2020

Conversation

emptynick
Copy link
Collaborator

@emptynick emptynick commented Apr 4, 2020

This allows relationship results to be sorted by defining the following in the options:

"sort": {
    "field": "my_field",
    "direction": "asc"
}

Fixes #3617

@codecov
Copy link

codecov bot commented Apr 4, 2020

Codecov Report

Merging #4858 into 1.4 will decrease coverage by 0.06%.
The diff coverage is 0.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##                1.4    #4858      +/-   ##
============================================
- Coverage     63.00%   62.93%   -0.07%     
- Complexity     1370     1373       +3     
============================================
  Files           194      194              
  Lines          3992     3996       +4     
============================================
  Hits           2515     2515              
- Misses         1477     1481       +4     
Impacted Files Coverage Δ Complexity Δ
src/Http/Controllers/VoyagerBaseController.php 57.21% <0.00%> (-0.58%) 143.00 <0.00> (+3.00) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7dc47eb...db21bbf. Read the comment docs.

Copy link
Collaborator

@MrCrayon MrCrayon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ordering works fine

}
```

This will sort the results ascending by the field `my_field`. Use `desc` as the direction to sort it in the opposite order.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If setting desc in the example this can be changed as:

This will sort the results descending by the field `my_field`. Default value for direction is `asc`.

@emptynick emptynick requested a review from MrCrayon April 6, 2020 11:49
@MrCrayon
Copy link
Collaborator

MrCrayon commented Apr 6, 2020

You can add Closes #3617

@emptynick
Copy link
Collaborator Author

Done

Copy link
Collaborator

@MrCrayon MrCrayon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍
Not sure if we need to specify that HasMany relationships won't be ordered.

@emptynick emptynick merged commit deea8d1 into thedevdojo:1.4 Apr 7, 2020
@emptynick emptynick deleted the relationship-order branch April 26, 2020 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How to sort relationship results
3 participants