wzq пре 5 година
родитељ
комит
3f591ec018
1 измењених фајлова са 14 додато и 1 уклоњено
  1. 14 1
      app/Transformers/Post/LogTransformer.php

+ 14 - 1
app/Transformers/Post/LogTransformer.php

@@ -15,12 +15,25 @@ class LogTransformer extends TransformerAbstract
 {
     public function transform(PostLog $postLog)
     {
+        $type = [
+            'add_pv' => '增加浏览量:',
+            'add_praise_count' => '增加点赞数:',
+            'add_collect_count' => '增加收藏数:',
+            'add_share_count' => '增加分享数:',
+        ];
+        $data = json_decode($postLog['content']);
+        $content = '';
+        foreach($data as $key => $val){
+            if(!$val) continue;
+            $content .= $type[$key] . $val .'、';
+        }
+        $content = rtrim($content, '、');
         return [
             'id' => $postLog['id'],
             'username' => $postLog['username'],
             'log_type' => $postLog['log_type'],
             'created_at' => Carbon::parse($postLog['created_at'])->toDateTimeString(),
-            'content' => $postLog['content'],
+            'content' => $content,
         ];
     }
 }