我有一个Orders有hasOne关系的模型participant。
public function participant()
{
return $this->hasOne('App\OrderParticipant', 'order_id');
}
我需要检索Orders按以下排序的集合participant.last_name
我的方法
$orders = \App\Orders::with(['participant',])
->where('user_id', $user->id)
->orderBy('participant.last_name')
->get();
失败:
未定义的表:7错误:缺少表\“参与者\” \ nLINE的FROM子句条目:... 1
收集后我试图对它进行排序
return $orders->sortBy('participant.last_name');
但这根本没有排序
顺便说一句我正在使用postgres
互换的青春