My project involves medical appointments using Laravel 4. Each appointment is linked to a doctor, a patient, a status, and one or more insurance cards.
So far this is working great:
$appointments = Appointment::
with('doctor','patient','status','insurances')->
orderBy($this->input['sidx'], $this->input['sord'])->
paginate($this->input['rows']);
The challenge is, sorting only works as long as I am sorting an attribute of the appointment. How would I adjust things if I wanted to sort by doctor.last_name or patient.last_name?