From 578d2f353dd16efdcae1c79fc082c714e0f28279 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 19 Jan 2020 21:51:21 -0700 Subject: [PATCH] Update DeleteAccountPipeline --- .../DeletePipeline/DeleteAccountPipeline.php | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/app/Jobs/DeletePipeline/DeleteAccountPipeline.php b/app/Jobs/DeletePipeline/DeleteAccountPipeline.php index 06e8191a6..735586576 100644 --- a/app/Jobs/DeletePipeline/DeleteAccountPipeline.php +++ b/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); }