【发布时间】:2018-04-13 15:18:55
【问题描述】:
用户
- uid
提供者
- pid
分辨率
- 摆脱
ProviderResolution
- 骄傲
- pid
- 摆脱
- 有效
ProviderResolutionUser
- 骄傲
- uid
class Provider extends Model {
public function resolutions()
{
return $this->belongsToMany('App\Models\Resolution')->withPivot('active')->withTimestamps();
}
}
class Resolution extends Model {
public function providers()
{
return $this->belongsToMany('App\Models\Provider')->withPivot('active')->withTimestamps();
}
}
class User extends Model
{
}
尝试与此建立 Eloquent 关系。
我试图弄清楚如何让用户适应这个模型。似乎它应该属于BelongsToMany。我需要创建一个代表枢轴的类吗?
那么从用户的情况下,我将如何查询列表分辨率?
【问题讨论】:
-
你不能只创建一个表
ProviderResolutionUser pid rid uid active吗? -
其实没有。如果用户变得不活动,我需要能够为用户禁用 ProviderResolution。我还需要向用户提供它们的列表。