|
@@ -87,18 +87,21 @@ class Article extends Model
|
|
|
public static function lst($where)
|
|
|
{
|
|
|
$model = new self;
|
|
|
- $model =$model->where('hidedata',0)->where('status',1);
|
|
|
- if(isset($where['cid']) && $where['cid']>0) $model = $model->where('cid',$where['cid']);
|
|
|
- if(isset($where['is_hot']) && $where['is_hot']==1) $model = $model->where('is_hotdata',$where['is_hot']);
|
|
|
- if(isset($where['is_rec']) && $where['is_rec']==1) $model = $model->where('is_recdata',$where['is_rec']);
|
|
|
+ $xwhere = null;
|
|
|
+ $xwhere['hidedata'] = 0;
|
|
|
+ $xwhere['status'] = 1;
|
|
|
+ if(isset($where['cid']) && $where['cid']>0) $xwhere['cid'] = $where['cid'];
|
|
|
+ if(isset($where['is_hot']) && $where['is_hot']==1) $xwhere['is_hotdata'] = $where['is_hot'];
|
|
|
+ if(isset($where['is_rec']) && $where['is_rec']==1) $xwhere['is_recdata'] = $where['is_rec'];
|
|
|
if(isset($where['ifyid']) && $where['ifyid']>0)
|
|
|
{
|
|
|
$ids = get_all_categories(ArticleCategory::lst(['cid'=>$where['cid']]),$where['ifyid']);
|
|
|
- $model = $model->wherein('article_category_id',$ids);
|
|
|
+ $xwhere['article_category_id'] =['in',$ids];
|
|
|
}
|
|
|
- if(isset($where['key']) && $where['key']!='') $model->whereLike('title',"%{$where['key']}%");
|
|
|
- $rs = $model->order('sort desc,id desc')->page($where['page'],$where['limit'])->select();
|
|
|
- return $rs;
|
|
|
+ if(isset($where['key']) && $where['key']!='') $xwhere['article_category_id'] = ['like',"%{$where['key']}%"];
|
|
|
+ $list = $model->where($xwhere)->order('sort desc,id desc')->page($where['page'],$where['limit'])->select();
|
|
|
+ $count = $model->where($xwhere)->count();
|
|
|
+ return compact('count','list');
|
|
|
|
|
|
}
|
|
|
|