作者 何书鹏

评论排序

@@ -246,7 +246,7 @@ class Index extends Api @@ -246,7 +246,7 @@ class Index extends Api
246 $goods['size'] = $user_size->visible(['id','name']); 246 $goods['size'] = $user_size->visible(['id','name']);
247 } 247 }
248 } 248 }
249 - $goods['appraise'] = \app\common\model\GoodsAppraise::getList(['goods_id'=>$goods_id],1,1); 249 + $goods['appraise'] = \app\common\model\GoodsAppraise::getList(['goods_id'=>$goods_id],['star'=>'desc'],1,1);
250 // 返回结果 250 // 返回结果
251 $this->success(__('成功'),compact('goods')); 251 $this->success(__('成功'),compact('goods'));
252 } 252 }
@@ -271,7 +271,7 @@ class Index extends Api @@ -271,7 +271,7 @@ class Index extends Api
271 $rows = $this->request->get('rows',null); 271 $rows = $this->request->get('rows',null);
272 $page = $this->request->get('page',1); 272 $page = $this->request->get('page',1);
273 $goods_id = $this->request->get('goods_id'); 273 $goods_id = $this->request->get('goods_id');
274 - $list = \app\common\model\GoodsAppraise::getList(['goods_id'=>$goods_id],$page,$rows); 274 + $list = \app\common\model\GoodsAppraise::getList(['goods_id'=>$goods_id],['createtime'=>'desc'],$page,$rows);
275 // 返回结果 275 // 返回结果
276 $this->success(__('成功'),compact('list')); 276 $this->success(__('成功'),compact('list'));
277 } 277 }
@@ -42,11 +42,11 @@ class GoodsAppraise extends Model @@ -42,11 +42,11 @@ class GoodsAppraise extends Model
42 /** 42 /**
43 * 评价列表 43 * 评价列表
44 */ 44 */
45 - public static function getList($where,$page,$rows) 45 + public static function getList($where,$order,$page,$rows)
46 { 46 {
47 $list = self::with(['user']) 47 $list = self::with(['user'])
48 ->where($where) 48 ->where($where)
49 - ->order(['star'=>'desc']) 49 + ->order($order)
50 ->paginate($rows,false,['page'=>$page]) 50 ->paginate($rows,false,['page'=>$page])
51 ->each(function($v){ 51 ->each(function($v){
52 $v->getRelation('user')->visible(['nickname','avatar']); 52 $v->getRelation('user')->visible(['nickname','avatar']);