浏览代码

Update DeleteAccountPipeline

Daniel Supernault 5 年之前
父节点
当前提交
578d2f353d
共有 1 个文件被更改,包括 18 次插入2 次删除
  1. 18 2
      app/Jobs/DeletePipeline/DeleteAccountPipeline.php

+ 18 - 2
app/Jobs/DeletePipeline/DeleteAccountPipeline.php

@@ -30,6 +30,8 @@ use App\{
     ReportLog,
     StatusHashtag,
     Status,
+    Story,
+    StoryView,
     User,
     UserDevice,
     UserFilter,
@@ -91,11 +93,25 @@ class DeleteAccountPipeline implements ShouldQueue
             Like::whereProfileId($id)->forceDelete();
         });
 
+        DB::transaction(function() use ($user) {
+            $pid = $this->user->profile_id;
+
+            StoryView::whereProfileId($pid)->delete();
+            $stories = Story::whereProfileId($pid)->get();
+            foreach($stories as $story) {
+                $path = storage_path('app/'.$story->path);
+                if(is_file($path)) {
+                    unlink($path);
+                }
+                $story->forceDelete();
+            }
+        });
+
         DB::transaction(function() use ($user) {
             $medias = Media::whereUserId($user->id)->get();
             foreach($medias as $media) {
-                $path = $media->media_path;
-                $thumb = $media->thumbnail_path;
+                $path = storage_path('app/'.$media->media_path);
+                $thumb = storage_path('app/'.$media->thumbnail_path);
                 if(is_file($path)) {
                     unlink($path);
                 }