示例#1
0
 public function delete()
 {
     // Remove all relationships
     $this->memberships()->detach();
     $this->medias()->detach();
     $this->pricelists()->delete();
     // Delete all media links
     foreach (ModuleMediaMembership::where('module_id', $this->id)->get() as $mmm) {
         $mmm->delete();
     }
     // Remove all relationships
     $this->tags()->detach();
     // Delete all images
     foreach ($this->images as $image) {
         $image->delete();
     }
     // Delete all translations
     $this->translations()->delete();
     // Delete asset images folder
     $upload_dir = \Config::get('redminportal::image.upload_dir');
     $deleteFolder = new Image();
     $url_path = RHelper::joinPaths($upload_dir, $this->table, $this->id);
     $deleteFolder->deleteFiles($url_path);
     return parent::delete();
 }
示例#2
0
 public function delete()
 {
     // Delete all images
     foreach ($this->images as $image) {
         $image->delete();
     }
     // Delete assets images folder
     $upload_dir = \Config::get('redminportal::image.upload_dir');
     $deleteFolder = new Image();
     $url_path = RHelper::joinPaths($upload_dir, $this->table, $this->id);
     $deleteFolder->deleteFiles($url_path);
     return parent::delete();
 }
示例#3
0
 public function delete()
 {
     // Remove all relationships
     $this->tags()->detach();
     $this->coupons()->detach();
     $this->orders()->detach();
     // Delete all images
     foreach ($this->images as $image) {
         $image->delete();
     }
     // Delete all translations
     $this->translations()->delete();
     // Delete asset images folder
     $upload_dir = \Config::get('redminportal::image.upload_dir');
     $deleteFolder = new Image();
     $url_path = RHelper::joinPaths($upload_dir, $this->table, $this->id);
     $deleteFolder->deleteFiles($url_path);
     return parent::delete();
 }
 private function moveFileOldToNew($image_folder, $image, $model_type)
 {
     $move_file = false;
     $filename_array = explode('/', $image->path);
     $filename = array_pop($filename_array);
     $old_img_dir = RHelper::joinPaths($image_folder, $model_type, $filename);
     $new_img_dir = RHelper::joinPaths($image_folder, $model_type, $image->imageable_id, $filename);
     $new_img_folder = RHelper::joinPaths($image_folder, $model_type, $image->imageable_id);
     if (file_exists(public_path() . '/' . $new_img_dir)) {
         $move_file = rename(public_path() . '/' . $new_img_dir, public_path() . '/' . $old_img_dir);
     }
     if ($move_file) {
         return $new_img_folder;
     } else {
         return false;
     }
 }
示例#5
0
 /**
  * Get URL of specified size
  * @param string $url
  * @param string $size
  * @return string $url
  */
 public function getUrl($url, $size = "thumb", $fullUrl = false)
 {
     // Get default dimensions
     $defaultDimensions = Config::get('redminportal::image.dimensions');
     // Get upload path
     $upload_path = Config::get('redminportal::image.upload_path');
     $dimension = $defaultDimensions[$size];
     // Get dimmensions and quality
     $width = (int) $dimension[0];
     $height = isset($dimension[1]) ? (int) $dimension[1] : $width;
     $crop = isset($dimension[2]) ? (bool) $dimension[2] : false;
     // URL info
     $info = pathinfo($url);
     // The size
     if (!$height) {
         $height = $width;
     }
     // Directories and file names
     $fileName = $info['basename'];
     $targetDirName = $width . 'x' . $height . ($crop ? '_crop' : '');
     $targetUrl = RHelper::joinPaths($upload_path . $info['dirname'], $targetDirName, $fileName);
     $relativeUrl = RHelper::joinPaths($info['dirname'], $targetDirName, $fileName);
     return $fullUrl ? $targetUrl : $relativeUrl;
 }
示例#6
0
 public function delete()
 {
     // Delete main category will delete all sub categories
     $this->categories()->delete();
     // Delete all images
     foreach ($this->images as $image) {
         $image->delete();
     }
     // Remove all relationships
     $this->bundles()->delete();
     $this->coupons()->detach();
     $this->medias()->delete();
     $this->modules()->delete();
     $this->pages()->delete();
     $this->portfolios()->delete();
     $this->posts()->delete();
     $this->products()->delete();
     $this->translations()->delete();
     // Delete category's images folder
     $upload_dir = \Config::get('redminportal::image.upload_dir');
     $deleteFolder = new Image();
     $url_path = RHelper::joinPaths($upload_dir, $this->table, $this->id);
     $deleteFolder->deleteFiles($url_path);
     return parent::delete();
 }