wesmiler пре 2 година
родитељ
комит
adb6092095
1 измењених фајлова са 5 додато и 5 уклоњено
  1. 5 5
      app/Services/Api/MessageService.php

+ 5 - 5
app/Services/Api/MessageService.php

@@ -70,16 +70,12 @@ class MessageService extends BaseService
         }
 
         $where = ['a.status'=>1,'a.mark'=>1];
-        if($userId){
-            $where['a.to_uid'] = $userId;
-        }
-
         $field = ['a.id','a.title','a.type','a.msg_type','a.chat_type','a.description','a.content','a.from_user_name','a.from_user_avatar','a.from_uid','a.to_user_name','a.to_user_avatar','a.to_uid','a.create_time','a.is_read','a.pages','a.status'];
         $datas = $this->model->from('message as a')
             ->leftJoin('member as b','b.id','=','a.from_uid')
             ->leftJoin('member as c','c.id','=','a.to_uid')
             ->where($where)
-            ->where(function($query) use($params){
+            ->where(function($query) use($params,$userId){
                 $fromUid = isset($params['from_uid'])? intval($params['from_uid']) : 0;
                 if($fromUid){
                     $query->where('a.from_uid', $fromUid);
@@ -89,6 +85,10 @@ class MessageService extends BaseService
                 if($type){
                     $query->where('a.type', $type);
                 }
+                
+                if($type != 9){
+                    $query->where('a.to_uid', $userId);
+                }
 
                 $chatType = isset($params['chat_type'])? intval($params['chat_type']) : 0;
                 if($chatType){