MedicOneSystems / MedicOneSystems/livewire-datatables
Sorting issue with filtered collection on callback
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 1.2k
- Forks
- 257
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
I got an issue when i try to sort a callback column on a filtered collection.
This is a short code example for reproduce the issue (i don't use $id into the callback function here, because it's just for the example, but i use it in my application in order to retrieve an Eloquent collection object) :
....
public function columns()
{
return [
Column::name('name'),
NumberColumn::callback('id', function ($id) {
$arr = [1, 5, 10, 4, 0, 9, 0, 8, 7, 5, 14, 3, 0, 2];
$collect = collect(array_rand($arr, 5));
$results = $collect->filter(function ($item) {
return $item > 4;
});
return $results->count();
}),
....
];
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the filtered-collection sorting behavior from the columns() example, focusing on the callback column and its returned collection. Trace how callback-column values are produced and sorted, then verify that sorting works correctly when the collection is filtered.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- laravel, php
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100