Browse Source

Update User\deleteAvatar()

Visman 4 years ago
parent
commit
baaee97733
1 changed files with 8 additions and 5 deletions
  1. 8 5
      app/Models/User/Model.php

+ 8 - 5
app/Models/User/Model.php

@@ -178,13 +178,16 @@ class Model extends DataModel
     public function deleteAvatar(): void
     {
         $file = $this->getAttr('avatar');
-        $path = $this->c->DIR_PUBLIC . "{$this->c->config->o_avatars_dir}/{$file}";
 
-        if (\is_file($path)) {
-            @\unlink($path);
-        }
+        if (! empty($file)) {
+            $path = $this->c->DIR_PUBLIC . "{$this->c->config->o_avatars_dir}/{$file}";
 
-        $this->avatar = '';
+            if (\is_file($path)) {
+                @\unlink($path);
+            }
+
+            $this->avatar = '';
+        }
     }
 
     /**