浏览代码

编辑话题

wzq 5 年之前
父节点
当前提交
a657990419
共有 1 个文件被更改,包括 5 次插入0 次删除
  1. 5 0
      app/Repositories/TopicRepository.php

+ 5 - 0
app/Repositories/TopicRepository.php

@@ -101,6 +101,7 @@ class TopicRepository {
                 'status_code'   => 500
             ]);
         }
+        $oldName = $topic->name;
         $_topic = $this->topic->where(['name'=>$request['name']])->where('id','<>',$topic->id)->first();
         if($_topic){
             return Response::create([
@@ -135,6 +136,10 @@ class TopicRepository {
                 }
             }
             DB::commit();
+            if($oldName != $topic->name){
+                Redis::zrem('topic.name', $oldName);
+                Redis::zadd('topic.name', $topic->id, $topic->name);
+            }
             return Response::create();
         }catch (QueryException $exception){
             DB::rollBack();