Laravel 什么';这两者之间有什么区别

Laravel 什么';这两者之间有什么区别,laravel,orm,relation,Laravel,Orm,Relation,这两者之间的区别是什么 return $this->belongsToMany('Acme\Models\User','friends','user_id','friend_id'); 及 有人能用sql解释一下吗 第三个参数是您所使用的模型的外键名称 正在定义关系,而第四个参数是 您要加入的模型的外键名称 在用户模型中应使用: return $this->belongsToMany('Acme\Models\Friend','friends','friend_id','user_

这两者之间的区别是什么

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

有人能用sql解释一下吗

第三个参数是您所使用的模型的外键名称 正在定义关系,而第四个参数是 您要加入的模型的外键名称

用户模型中应使用:

return $this->belongsToMany('Acme\Models\Friend','friends','friend_id','user_id');
朋友模式中

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

为什么不打印查询并自己探索?我如何打印查询?->toSql()dosent workJust QueryLog如下
$querys=DB::getQueryLog()$最后一次查询=结束($querys)
return $this->belongsToMany('Acme\Models\User','friends','user_id','friend_id');