I need to sort based on 2 fields a timeline of records that I have. In this result set I have these columns:
timeline:
- minutes (int);
- text;
- created_at (date_time);
In my timeline it is possible to have multiple text lines in the same minute. So having this in consideration, first I want to sort by minute, and then by created_at (in case I have multiple texts lines in the same minute).
My query doesn't work: I have for example minute 74 showing after 94 in DESC, and this is because in making the sort by both minute and created_at. I need to make sure that my sort is first in minutes, and then by created_at.
My code:
$timelineFeed = SoccerMatchTimeline::where('soccer_match_id',$id)
->orderBy('created_at', 'DESC')
->orderBy('minute', 'desc')->get();