/** * Upload array of images .. * * @param $images * @param $path * @param array $filters * @param null $placeholder * @param callable $closure * @return array */ public function upload($images, $path = null, array $filters = [], $placeholder = null, \Closure $closure = null) { if (!is_array($images)) { $images = (array) $images; } return array_map(function ($image) use($path, $filters, $placeholder, $closure) { $image = app('image')->make($image); $image = $this->applyFilters($image, $filters); if (is_null($path)) { $path = $this->getStorePath(); } if (!Support\is_path_exists($path)) { Support\mk_path($path); } if (!is_null($placeholder)) { $filename = sprintf('%s.%s', $placeholder, $this->guessExtension($image)); } else { $filename = sprintf('%s.%s', uniqid(), $this->guessExtension($image), $this->getQuality()); } $image->relative_path = $this->getStorePath(false) . DIRECTORY_SEPARATOR . $filename; if (!is_null($closure)) { $image = $closure($image); } return $image->save($path . DIRECTORY_SEPARATOR . $filename); }, array_filter($images)); }
/** * Get default path . * * @param null $filename * @return string */ protected function fullPath($filename = null) { if (!($path = config('laravel-exporter')['default_path'])) { $path = ''; } #@todo check for storage path, we need use without laravel . $path = storage_path($path); if (is_null($filename)) { $filename = $this->getFilename(); } if (!Support\is_path_exists($path)) { Support\mk_path($path); } return $path . DIRECTORY_SEPARATOR . $filename; }