【发布时间】:2023-02-04 19:27:38
【问题描述】:
合同有代表(即用户)。
目前我在我的 Contract 模型中直接与 belongsTo 建立了这种关系:
class Contract extends Model
{
public function representative()
{
return $this->belongsTo(User::class);
}
我希望能够通过 organization_user 表检索此关系并检索“位置”属性。 我想我应该使用 hasOneThrough 关系,但我找不到我要找的东西。
class Contract extends Model
{
public function representative()
{
return $this->hasOneThrough(User::class, OrganizationUser::class);
}
【问题讨论】: