我在下面有这两个表,我想在from代码和where代码之间建立关系,以便我可以使用$proc->from->name
访问国家名称
我已经尝试过了,但是没用
public function from()
{
return $this->hasOne('App\Country', 'from', 'code');
}
public function where()
{
return $this->hasOne('App\Country', 'where', 'code');
}
过程:
id | user_id | from | where
--------------------------------
1 | 1 | GB | US
2 | 2 | AZ | TR
国家
id | name | code |
------------------------
1 |United States | US |
2 | France | FR |