|
|
@@ -83,12 +83,12 @@ class SocialService extends BaseService
|
|
|
|
|
|
$type = isset($params['type'])?intval($params['type']) : 0;
|
|
|
if($type==1){
|
|
|
- $query->orderBy('a.views','desc');
|
|
|
+ $query->orderBy('posts.views','desc');
|
|
|
}else{
|
|
|
- $query->orderBy('a.id','desc');
|
|
|
+ $query->orderBy('posts.id','desc');
|
|
|
}
|
|
|
|
|
|
- $list = $query->select(['a.*'])->withCount(['likes'])->paginate($pageSize > 0 ? $pageSize : 9999999);
|
|
|
+ $list = $query->select(['posts.*'])->withCount(['likes'])->paginate($pageSize > 0 ? $pageSize : 9999999);
|
|
|
$list = $list? $list->toArray() :[];
|
|
|
|
|
|
return [
|
|
|
@@ -105,34 +105,34 @@ class SocialService extends BaseService
|
|
|
*/
|
|
|
public function getQuery($params)
|
|
|
{
|
|
|
- $where = ['a.mark' => 1];
|
|
|
+ $where = ['posts.mark' => 1];
|
|
|
$status = isset($params['status'])? $params['status'] : 0;
|
|
|
$type = isset($params['type'])? $params['type'] : 0;
|
|
|
$userId = isset($params['user_id'])? $params['user_id'] : 0;
|
|
|
|
|
|
if($status>0){
|
|
|
- $where['a.status'] = $status;
|
|
|
+ $where['posts.status'] = $status;
|
|
|
}
|
|
|
|
|
|
if($type>0){
|
|
|
- $where['a.type'] = $type;
|
|
|
+ $where['posts.type'] = $type;
|
|
|
}
|
|
|
|
|
|
|
|
|
return $this->model->with(['user','isLike'=>function($query) use($userId){
|
|
|
$query->where('user_id', $userId);
|
|
|
- }])->from('posts as a')
|
|
|
+ }])->from('posts')
|
|
|
->where($where)
|
|
|
->where(function ($query) use($params){
|
|
|
$keyword = isset($params['keyword'])? $params['keyword'] : '';
|
|
|
if($keyword){
|
|
|
- $query->where('a.title','like',"%{$keyword}%")
|
|
|
- ->orWhere('a.tags','like',"%{$keyword}%");
|
|
|
+ $query->where('posts.title','like',"%{$keyword}%")
|
|
|
+ ->orWhere('posts.tags','like',"%{$keyword}%");
|
|
|
}
|
|
|
|
|
|
$tag = isset($params['tag'])? $params['tag'] : '';
|
|
|
if($tag){
|
|
|
- $query->where('a.tags','like',"%{$tag},%");
|
|
|
+ $query->where('posts.tags','like',"%{$tag},%");
|
|
|
}
|
|
|
});
|
|
|
}
|