I have a model called School and it has many Students .
Here is the code in my model:
public function students()
I am getting all the students with this code in my controller:
$school = School::find($schoolId);
and in the view:
@foreach ($school->students as $student)
Now I want to order the Students by some field in the students table. How can I do that?