Exemplo n.º 1
0
Arquivo: Image.php Projeto: semnt/tp01
 public function deleteImage()
 {
     foreach (['source', 'big', 'mid'] as $type) {
         $path = $this->{"path_to_{$type}"};
         if (strlen($path)) {
             FileHelper::unlink(static::getAbsPath($path));
         }
         $this->{"path_to_{$type}"} = null;
     }
 }
Exemplo n.º 2
0
Arquivo: Image.php Projeto: semnt/tp01
 public function save()
 {
     $model = parent::save();
     if (strlen($this->upload_key)) {
         if ($this->upload_key == '__clear__') {
             $model->deleteImage();
             $model->save();
         } else {
             $path = \app\helpers\Upload::getTmpUploadPath($this->upload_key);
             if (is_file($path)) {
                 $model->pullImage($path);
                 $model->save();
                 FileHelper::unlink($path);
             }
         }
     }
     return $model;
 }