wesmiler 5 giorni fa
parent
commit
e7aa27a682
1 ha cambiato i file con 10 aggiunte e 10 eliminazioni
  1. 10 10
      app/Services/Api/SocialService.php

+ 10 - 10
app/Services/Api/SocialService.php

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