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();