Quellcode durchsuchen

用户使用话题次数

wzq vor 5 Jahren
Ursprung
Commit
88529e46b6
1 geänderte Dateien mit 6 neuen und 3 gelöschten Zeilen
  1. 6 3
      app/Repositories/Post/PostRepository.php

+ 6 - 3
app/Repositories/Post/PostRepository.php

@@ -68,15 +68,15 @@ class PostRepository
 //            ]);
 //        }
         //验证话题
-        $topicIds = $this->topic->whereIn('id', explode(',', $request['topic_ids']))->pluck('id')->toArray();
-        $topicCount = count($topicIds);
+        $topicIdsArray = $this->topic->whereIn('id', explode(',', $request['topic_ids']))->pluck('id')->toArray();
+        $topicCount = count($topicIdsArray);
         if($topicCount == 0 || $topicCount > 5){
             return Response::create([
                 'message'  => '所选话题必须1-5个',
                 'status_code'   => 500
             ]);
         }
-        $topicIds = implode(',', $topicIds);
+        $topicIds = implode(',', $topicIdsArray);
 
         //验证内容字数
         $html = preg_replace("/<([a-zA-Z]+)[^>]*>/","<\\1>",$request['content']);
@@ -143,6 +143,9 @@ class PostRepository
 
             DB::commit();
             Redis::zadd('post_trigger_type', 0, $post->id);
+            foreach($topicIdsArray as $id){
+                Redis::zincrby('topic.user_uid'.$request['uid'], 1, $id);
+            }
             return Response::create();
 
         }catch (QueryException $exception){