Apr 11, 2022
0
Level 1
SortDesc and SortBy Collection for custom data
I have one eloquent query and two custom array. $priority_call -> is a list ('pending','await', etc.) created by $collection->filter based on conditional query. $queue_list -> is a list ('high', 'medium', 'low') is a static array. $data_cal = is results of a query column.
How can I sort like this? priority_call -> sort by DESC queue_list -> sort by ASC (here solved with array_reverse) data_cal -> sort by ASC(here is my problem)
$collection = $collection->sortByDesc(function($leads) use($request) {
$priority_call = $this->priorityCall($leads->status_group);
$queue_list = array_search($leads->status_group, array_reverse(explode(',',$leads->online_operators->queue_list)));
$data_cal = $leads->data_cal;
return [
$priority_call,
$queue_list
$data_cal,
];
})->values();
Please or to participate in this conversation.