作者 何书鹏

评论排序

... ... @@ -246,7 +246,7 @@ class Index extends Api
$goods['size'] = $user_size->visible(['id','name']);
}
}
$goods['appraise'] = \app\common\model\GoodsAppraise::getList(['goods_id'=>$goods_id],1,1);
$goods['appraise'] = \app\common\model\GoodsAppraise::getList(['goods_id'=>$goods_id],['star'=>'desc'],1,1);
// 返回结果
$this->success(__('成功'),compact('goods'));
}
... ... @@ -271,7 +271,7 @@ class Index extends Api
$rows = $this->request->get('rows',null);
$page = $this->request->get('page',1);
$goods_id = $this->request->get('goods_id');
$list = \app\common\model\GoodsAppraise::getList(['goods_id'=>$goods_id],$page,$rows);
$list = \app\common\model\GoodsAppraise::getList(['goods_id'=>$goods_id],['createtime'=>'desc'],$page,$rows);
// 返回结果
$this->success(__('成功'),compact('list'));
}
... ...
... ... @@ -42,11 +42,11 @@ class GoodsAppraise extends Model
/**
* 评价列表
*/
public static function getList($where,$page,$rows)
public static function getList($where,$order,$page,$rows)
{
$list = self::with(['user'])
->where($where)
->order(['star'=>'desc'])
->order($order)
->paginate($rows,false,['page'=>$page])
->each(function($v){
$v->getRelation('user')->visible(['nickname','avatar']);
... ...