0

i try to work this situation. i have table with results. until now i used ->orderBy('final') but i found out that is not working when i have same final time.

  Left time |  Right time  |  Final
0    24:45       24:22        24:45
1    24:85       21:84        24:85
2    24:44       25:12        25:12
3    25:12       21:78        25:12
4    38:12       25:99        38:12

problem is when i have equal final time like index [2],[3] and when is situation like that i want check better time Left time or Right time and sort them again..

so finally it must look like (index 2, 3 switch)

  Left time |  Right time  |  Final
0    24:45       24:22        24:45
1    24:85       21:84        24:85
2    25:12       21:78        25:12
3    24:44       25:12        25:12
4    38:12       25:99        38:12
mickmackusa
  • 43,625
  • 12
  • 83
  • 136
pribor
  • 33
  • 5

2 Answers2

2

You may use the following

Model::orderByRaw("column1 DESC, column2 DESC");
    ->get();
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Foued MOUSSI
  • 4,643
  • 3
  • 19
  • 39
2

You can use orderBy multiple times.

MyTable::orderBy('column1', 'DESC')
    ->orderBy('column2', 'ASC')
    ->get();