Update avatar deletion

This commit is contained in:
Daniel Supernault 2019-05-27 20:03:19 -06:00
parent 14fa51fa30
commit a641db0764
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7
2 changed files with 7 additions and 12 deletions

View file

@ -74,17 +74,6 @@ class DeleteAccountPipeline implements ShouldQueue
if($user->profile) { if($user->profile) {
$avatar = $user->profile->avatar; $avatar = $user->profile->avatar;
if(is_file($avatar->media_path)) {
if($avatar->media_path != 'public/avatars/default.png') {
unlink($avatar->media_path);
}
}
if(is_file($avatar->thumb_path)) {
if($avatar->thumb_path != 'public/avatars/default.png') {
unlink($avatar->thumb_path);
}
}
$avatar->forceDelete(); $avatar->forceDelete();
} }

View file

@ -48,7 +48,13 @@ class AvatarObserver
public function deleting(Avatar $avatar) public function deleting(Avatar $avatar)
{ {
$path = storage_path('app/'.$avatar->media_path); $path = storage_path('app/'.$avatar->media_path);
@unlink($path); if(is_file($path) && $avatar->media_path != 'public/avatars/default.png') {
@unlink($path);
}
$path = storage_path('app/'.$avatar->thumb_path);
if(is_file($path) && $avatar->thumb_path != 'public/avatars/default.png') {
@unlink($path);
}
} }
/** /**