class Theme extends BaseModel{ ? ?public function products(){ ? ? ? ?return $this -> belongsToMany( ? ? ? ? ? ?'Product','theme_product','product_id','theme_id' ? ? ? ?); ? ?} ? ?public static function getRecentTheme(){ ? ? ? ?$themes = self::with('Products') -> select(); ? ? ? ?return $themes; ? ?}}Theme 當(dāng)前模型Product 關(guān)聯(lián)模型theme_product 中間表想對(duì)Product下的內(nèi)容進(jìn)行排序!想對(duì)Product下的內(nèi)容進(jìn)行排序!想對(duì)Product下的內(nèi)容進(jìn)行排序! 重要的事說(shuō)3次~~~跪求大神
5 回答

慕粉3704614
TA貢獻(xiàn)1條經(jīng)驗(yàn) 獲得超2個(gè)贊
public?function?products(){ ????????return?$this?->?belongsToMany('Product','theme_product','product_id','theme_id')->order('product_id?DESC'); ????}

獣灬
TA貢獻(xiàn)1條經(jīng)驗(yàn) 獲得超0個(gè)贊
$themes = self::with(['Products'=>function($query){$query->order('id desc')}]) -> select();
- 5 回答
- 0 關(guān)注
- 6058 瀏覽
添加回答
舉報(bào)
0/150
提交
取消