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
1
  • You should be able to use orderByRaw() and add more than one column of sorting. Have you tried that? Commented Apr 16, 2020 at 12:46

2 Answers 2

2

You may use the following

Model::orderByRaw("column1 DESC, column2 DESC");
    ->get();
Sign up to request clarification or add additional context in comments.

Comments

2

You can use orderBy multiple times.

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.