1
我看了一下雄辯的關係https://laravel.com/docs/5.2/eloquent-relationships#one-to-one。laravel一對一關係:交換方法
我的問題是:切換hasOne和belongsTo有區別嗎?
Laravel文檔:
public function phone()
{
return $this->hasOne('App\Phone');
}
public function user()
{
return $this->belongsTo('App\User');
}
我可以換樣方法:
public function phone()
{
return $this->belongsTo('App\Phone');
}
public function user()
{
return $this->hasOne('App\User');
}