How to do sorting by two parameters with Laravel 5.4?

3

I am doing a descending order to list winners, however it is based on note.

My search is as follows:

public function getHistorico($id_avaliacao)
{
    return $this->where('avaliacao_id', $id_avaliacao)
        ->orderBy('nota', 'desc')
        ->get();
}

I would like to make sure that if the note of two employees is equal, the employee with data_admissao less is listed before, can you do this using eloquent ?     

asked by anonymous 23.02.2017 / 14:30

1 answer

3

Try this:

$this->where('avaliacao_id', $id_avaliacao)
     ->orderBy('nota', 'desc')
     ->orderBy('data_admissao', 'asc')
     ->get();

You can invoke orderBy as often as you like

    
23.02.2017 / 14:33