浏览代码

Update FixDuplicateProfiles command

Daniel Supernault 2 年之前
父节点
当前提交
e4e7b5062a
共有 1 个文件被更改,包括 14 次插入2 次删除
  1. 14 2
      app/Console/Commands/FixDuplicateProfiles.php

+ 14 - 2
app/Console/Commands/FixDuplicateProfiles.php

@@ -155,8 +155,20 @@ class FixDuplicateProfiles extends Command
 
     protected function checkFollowers($id, $oid)
     {
-        Follower::whereProfileId($oid)->where('profile_id', '!=', $id)->update(['profile_id' => $id]);
-        Follower::whereFollowingId($oid)->where('following_id', '!=', $id)->update(['following_id' => $id]);
+        $f = Follower::whereProfileId($oid)->pluck('following_id');
+        foreach($f as $fo) {
+            Follower::updateOrCreate([
+                'profile_id' => $id,
+                'following_id' => $fo
+            ]);
+        }
+        $f = Follower::whereFollowingId($oid)->pluck('profile_id');
+        foreach($f as $fo) {
+            Follower::updateOrCreate([
+                'profile_id' => $fo,
+                'following_id' => $id
+            ]);
+        }
     }
 
     protected function checkHashtagFollow($id, $oid)