【发布时间】:2015-04-02 22:57:05
【问题描述】:
我有一对一的关系,我正试图在 laravel 中工作。
我正在尝试使用user 和alert 表。
User 表的主键是id,其中的另一个 id 称为id_custom。
在Alerts 表中,我将id_custom 作为主键。
这是用户模型中的关系:
public function alerts()
{
return $this->hasOne('Alerts', 'id_custom');
}
这是警报模型:
alerts->profit`(其中 `profit` 是 `Alerts` 表中的一列。 我究竟做错了什么?【问题讨论】:
-
你试过
return $this->hasOne(Alerts', 'id_custom', 'id')吗?