You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In a select dropdown relationship, datas are not sorting as defined in the sort option of the relationship
Steps to reproduce
My Model : Parcours belongsto Cadre, with a sort on the name
When adding a Parcour, the select dropdown loads datas 50 by 50
(I show the json results)
Page 1
Page 2
Page 3
It seems that datas are sorted by id, then by name for Page 1 and 2
By name then by id on page 3.
Expected behavior
The relation datas must be sorted by 'name' first, then take/limit and skip/offset.
In voyagerBaseController->relation, some changes since this fixe #4858 to include sorting
But sorting is done after take/limit and skip/offset.
For sample, line 928 $relationshipOptions = $model->take($on_page)->skip($skip)->get();
and line 945 $relationshipOptions = $relationshipOptions->sortBy($options->sort->field);
I tried $relationshipOptions = $model->get()->sortBy($options->sort->field)->take($on_page)->skip($skip);
It's OK for Page 1, the first 50 datas are sorted by name, but next pages are empty.
I think there is some changes to do between line 911 and 947.
Screenshots
No response
Additional context
No response
The text was updated successfully, but these errors were encountered:
This issue has been automatically locked since there has not been any recent activity after it was closed. If you have further questions please ask in our Slack group.
Laravel version
9.7.0
PHP version
8.1.4
Voyager version
1.5
Database
8.0.28
Description
In a select dropdown relationship, datas are not sorting as defined in the sort option of the relationship
Steps to reproduce
My Model : Parcours belongsto Cadre, with a sort on the name
When adding a Parcour, the select dropdown loads datas 50 by 50
(I show the json results)
Page 1
Page 2
Page 3
It seems that datas are sorted by id, then by name for Page 1 and 2
By name then by id on page 3.
Expected behavior
The relation datas must be sorted by 'name' first, then take/limit and skip/offset.
In voyagerBaseController->relation, some changes since this fixe #4858 to include sorting
But sorting is done after take/limit and skip/offset.
For sample, line 928
$relationshipOptions = $model->take($on_page)->skip($skip)->get();
and line 945
$relationshipOptions = $relationshipOptions->sortBy($options->sort->field);
I tried
$relationshipOptions = $model->get()->sortBy($options->sort->field)->take($on_page)->skip($skip);
It's OK for Page 1, the first 50 datas are sorted by name, but next pages are empty.
I think there is some changes to do between line 911 and 947.
Screenshots
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: