We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hi @pascalbaljet
I'm trying to sort collection in many ways but not result, each time $complaintsSearch returned unsorted data.
Few examples:
$complaints = (new Complaint); $sortBy = [['complaints_date','desc'],['city','desc']]; $complaintsSearch = Search::add($complaints, 'company_name') ->search('"' . $searchText . '"'); $complaintsSearch = $complaintsSearch->toArray(); usort($complaintsSearch, function($a, $b) { return -strcmp($a['complaint_date'], $b['complaint_date']); });
$complaintsSearch = collect($complaintsSearch); $complaintsSearch = $complaintsSearch->sortByDesc(function ($item) { return (string) $item['complaint_date']; });
$complaintsSearch = $complaintsSearch->sortBy(function($complaintsSearch) use ($sortBy) { foreach ($sortBy as $sort) { $column = $sort[0]; $direction = $sort[1]; if ($direction == 'asc') { return $complaintsSearch->$column; } else { return $complaintsSearch->$column; } }
And I also trygin sorting data before pass it.
$complaints->orderBy($sortBy);
Each time it returned unsorted collection I don't know why.
Sorting working correctly without use Search
Sorry for misspelled
Thank you.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Hi @pascalbaljet
I'm trying to sort collection in many ways but not result, each time $complaintsSearch returned unsorted data.
Few examples:
And I also trygin sorting data before pass it.
$complaints->orderBy($sortBy);
Each time it returned unsorted collection I don't know why.
Sorting working correctly without use Search
Sorry for misspelled
Thank you.
The text was updated successfully, but these errors were encountered: