Eloquent eager load Order by

后端 未结 7 2084
花落未央
花落未央 2020-11-27 13:56

I have problem with eloquent query. I am using eager loading (one to one Relationship) to get \'student\' With the \'exam\', Using the code

相关标签:
7条回答
  • 2020-11-27 14:56

    Try this:

    Student::with(array('exam' => function($query) {
            $query->orderBy('result', 'DESC');
        }))
        ->get();
    
    0 讨论(0)
提交回复
热议问题