Exemplo n.º 1
0
 /**
  * $this
  * @param StoresMedia $owner
  * @param $size
  */
 public function handleOwner(StoresMedia $owner, $size)
 {
     if ($owner->mediaStoresMultiple()) {
         foreach ($owner->images as $image) {
             $this->handleImage($image);
         }
     } elseif ($owner->images) {
         $this->handleImage($owner->images);
     }
     $this->files->deleteDirectory(rtrim($this->config->getPublicPath($owner, 'images', $size), '/'));
 }
Exemplo n.º 2
0
 /**
  * @param $model
  */
 protected function addImages($model)
 {
     $options = ['one_image' => ['PORTFOLIO_O14A0464.jpg'], 'two_images' => ['PORTFOLIO_O14A0464.jpg', 'PORTFOLIO_IMG_0331.jpg'], 'three_images' => ['PORTFOLIO_IMG_0324.jpg', 'PORTFOLIO_IMG_0331.jpg', 'PORTFOLIO_O14A0464.jpg']];
     $images = array_rand($options, 1);
     $source = database_path('images/' . $images);
     $destination = $this->mediaConfig->getPublicPath($model, 'images');
     $this->files->copyDirectory($source, $destination);
     $files = scandir($destination);
     $files = array_filter($files, function ($file) {
         return !in_array($file, ['.', '..', '.DS_Store']);
     });
     foreach ($files as $file) {
         if ($this->files->isDirectory($destination . $file)) {
             $sizes[] = $file;
         }
     }
     foreach ($options[$images] as $name) {
         $original = $this->addMain($model, $destination, $name);
         $this->addSizes($model, $sizes, $original, $destination, $name);
     }
 }
Exemplo n.º 3
0
 /**
  * @param Filesystem $files
  * @param Configurator $config
  */
 protected function handleFile(Filesystem $files, Configurator $config)
 {
     $abstract = $config->getAbstractPath($this->owner, 'images');
     $public = $config->getPublicPath($this->owner, 'images');
     if (!$files->isDirectory($public)) {
         $files->makeDirectory($public, 0755, true);
     }
     //abstract path to actual file
     $path = $abstract . $this->rename;
     //always copy the file first
     $files->copy($this->currentPath, public_path($path));
     $this->path = $path;
 }