Hi All,
I am looking for a bit of assistance on a small issue if some good folks have the time.
Take the result of this collection below.
array:6 [
0 => {#710
+"chatConversationId": 110
+"startTime": "2017-02-22T11:14:46.567"
+"summary": "Hello from a patient"
+"priorityTag": "Low"
}
1 => {#709
+"chatConversationId": 112
+"startTime": "2017-02-22T11:14:46.72"
+"summary": null
+"priorityTag": "Medium"
}
2 => {#700
+"chatConversationId": 113
+"startTime": "2017-02-22T11:15:25.15"
+"summary": null
+"priorityTag": "Low"
}
3 => {#701
+"chatConversationId": 114
+"startTime": "2017-02-22T11:15:25.37"
+"summary": null
+"priorityTag": "High"
}
4 => {#702
+"chatConversationId": 115
+"startTime": "2017-02-22T11:15:25.493"
+"summary": null
+"priorityTag": "High"
}
5 => {#703
+"chatConversationId": 116
+"startTime": "2017-02-22T11:15:25.557"
+"summary": null
+"priorityTag": null
}
]
How do I order this collection so that the items are ordered by priority and by date ascending? In effect what I would like would be the results to look like this:
array:6 [
0 => {#701
+"chatConversationId": 114
+"startTime": "2017-02-22T11:15:25.37"
+"summary": null
+"priorityTag": "High"
}
1 => {#702
+"chatConversationId": 115
+"startTime": "2017-02-22T11:15:25.493"
+"summary": null
+"priorityTag": "High"
}
2 => {#709
+"chatConversationId": 112
+"startTime": "2017-02-22T11:14:46.72"
+"summary": null
+"priorityTag": "Medium"
}
3 => {#700
+"chatConversationId": 113
+"startTime": "2017-02-22T11:15:25.15"
+"summary": null
+"priorityTag": "Low"
}
4 => {#710
+"chatConversationId": 110
+"startTime": "2017-02-22T11:14:46.567"
+"summary": "Hello from a patient"
+"priorityTag": "Low"
}
5 => {#703
+"chatConversationId": 116
+"startTime": "2017-02-22T11:15:25.557"
+"summary": null
+"priorityTag": null
}
]
I have attempted to use the sortBy and sortByDesc methods either on their own or combined and the results come back incorrect.
$conversations->filter(function ($conversation) {
return (string)$conversation->status === 'Open';
})->sortBy(function ($conversation) {
return $conversation->priorityTag;
})->sortBy(function ($conversation) {
return $conversation->startTime;
})->values()->all();
Now I could just be doing this incorrectly, but any ideas would be very helpful... Thanks...