这些有什么区别

what's difference between these

这些有什么区别?

return $this->belongsToMany('Acme\Models\User','friends','user_id','friend_id');

return $this->belongsToMany('Acme\Models\User','friends','friend_id','user_id');

有人可以用 sql 解释一下吗?

The third argument is the foreign key name of the model on which you are defining the relationship, while the fourth argument is the foreign key name of the model that you are joining to.

用户模型中你应该使用:

return $this->belongsToMany('Acme\Models\Friend','friends','friend_id','user_id');

并且在好友模型中:

return $this->belongsToMany('Acme\Models\User','friends','user_id','friend_id');