xiaogang 4 år sedan
förälder
incheckning
4296768534
1 ändrade filer med 10 tillägg och 2 borttagningar
  1. 10 2
      app/Services/NoticeService.php

+ 10 - 2
app/Services/NoticeService.php

xqd xqd xqd xqd
@@ -7,6 +7,7 @@ namespace App\Services;
 use App\Models\DynamicZanModel;
 use App\Models\UserLikeModel;
 use App\Models\UserSystemMessageModel;
+use function Symfony\Component\Translation\t;
 
 class NoticeService
 {
@@ -54,7 +55,11 @@ class NoticeService
         $query = DynamicZanModel::query();
         if($param['type']==1){
             //他赞了我
-            $query = $query->with(['dynamic','user','user_info'])->whereHas('dynamic',function ($query)use($param){
+            $query = $query->with(['dynamic','user'=>function($query){
+                $query->select('id','sex','is_vip','tencent_im_user_id');
+            },'user_info'=>function($query){
+                $query->select(['user_id','nickname','avatar','height','weight','work']);
+            }])->whereHas('dynamic',function ($query)use($param){
                 $query->where('user_id',$param['user_id'])->select();
             });
 
@@ -69,7 +74,9 @@ class NoticeService
                 $query->select('id','user_id','content','img_url');
             },'dynamic.user'=>function($querty){
                 $querty->select('id','sex','is_vip','tencent_im_user_id');
-            },'dynamic.user_info'])
+            },'dynamic.user_info'=>function($querty){
+                $querty->select(['user_id','nickname','avatar','height','weight','work']);
+            }])
                 ->where('user_id',$param['user_id']);
         }
         $query = $query->orderByDesc('id')
@@ -77,6 +84,7 @@ class NoticeService
 
         $query = $query->toArray();
         foreach ($query['data'] as $k=>$v){
+            $query['data'][$k]['atime'] = uc_time_ago($v['atime']);
             $query['data'][$k]['dynamic']['img_url'] = json_decode($v['dynamic']['img_url'],true);
         }
         return $query;