I have problem with eloquent query. I am using eager loading (one to one Relationship) to get \'student\' With the \'exam\', Using the code
There is an alternative way of achieving the result you want to have without using joins. You can do the following to sort the students based on their exam's result. (Laravel 5.1):
$students = Student::with('exam')->get();
$students = $students->sortByDesc(function ($student, $key)
{
return $student->exam->result;
});