【发布时间】:2015-03-27 00:46:45
【问题描述】:
我确实有色板表、颜色表和 swatch_color 数据透视表。
关系设置为:
public function colors()
{
return $this->belongsToMany('Color');
}
public function swatches()
{
return $this->belongsToMany('Swatch');
}
我可以毫无问题地检索具有颜色关系的样本
$swatches = Swatch::with('colors')->get();
return dd($swatches);
Colors 始终是具有色调、R、G 和 B 属性的 5 个颜色对象的数组。
现在我想按第一个相关颜色的 R 值对色板进行排序。
【问题讨论】:
标签: sorting laravel many-to-many eloquent relationship