0
我在我的數據庫中有一對多表,它們有多對多的關係。我在模型中,從而連接它們...可以排序(order_by)多對多關係的結果嗎?
public function tags()
{
return $this->belongsToMany('Tag', 'user_tag')->withPivot('otherStuff');
}
我想的結果,按字母順序排序,這樣的事情...
public function tags()
{
return $this->belongsToMany('Tag', 'user_tag')->withPivot('otherStuff')->order_by('name', 'asc');
}
我試過的代碼,但Laravel 4失敗並抱怨order_by不存在。有什麼建議麼?