/**
  * @param Brand $model
  *
  * @return bool
  */
 public function saving(Brand $model)
 {
     // process the image, only if it is there or if it's modified
     if ($model->isDirty('logo')) {
         $path = $this->image->init($model, 'logo')->getImage();
         if (empty($path)) {
             return false;
         }
         $model->logo = $path;
         return true;
     }
     return true;
 }
 /**
  * @param User $model
  *
  * @return bool
  */
 public function saving(User $model)
 {
     // process the image, only if it is there / modified
     if ($model->isDirty('avatar')) {
         // delete old avatar
         $deleteResult = $this->deleteOldImages($model);
         // check if the avatar is a url path. we would skip it
         if (is_string($model->avatar)) {
             return true;
         }
         $path = $this->image->init($model, 'avatar')->getImage();
         if (empty($path)) {
             return false;
         }
         $model->avatar = $path;
         return true;
     }
     return true;
 }
 /**
  * @param Product $model
  *
  * @return bool
  */
 public function saving(Product $model)
 {
     // if there is a new image, then do sth. otherwise leave the original one
     if ($model->isDirty('image')) {
         // check if old product images exist on the filesystem and delete them
         $deleteResult = $this->deleteProductImages($model);
         $path = $this->image->init($model, 'image')->getImage();
         if (empty($path)) {
             return false;
         }
         $model->image_large = $path;
         // create the small image
         $model->image = $this->image->reduceImage($model->image_large, config('site.products.images.reduce_ratio'));
         if (is_null($model->image_large or is_null($model->image))) {
             // error. just bail out
             return false;
         }
         return true;
     }
     return true;
 }