所以我有2个模型,User& 配置文件,关系设置如下: p>
/ **
*用户属于许多配置文件
*
* @return \ Illuminate \ Database \ Eloquent \ Relations \ belongsToMany
* /
公共功能配置文件()
{
返回$ this-> belongsToMany('App \ Models \ Profile','user_profiles');
}
code> < / pre>
我有3个表,用户,个人资料和 user_profiles(数据透视表) p>
我的users表中有一个名为 active_profile code>的列,其中填充了配置文件ID。 p>
如何设置关系以便我可以调用以下内容: p>
$ user-&gt; active_profile 代码> p>
这样它将返回active_profile中设置的id的所有配置文件信息? p>
div>