/** * @param Filesystem $files * @param AccountManager $manager * @return mixed */ public function handle(Filesystem $files, AccountManager $manager) { $temp_dir = storage_path('media') . '/' . $this->owner->getMediaFolder('images'); $name = $this->uniqueName(); $this->image->move($temp_dir, $name); $temp_file = $temp_dir . $name; $name_with_extension = $name . $this->extension($temp_file); $final_path = $temp_file . $name_with_extension; $files->move($temp_file, $final_path); $image = $this->dispatch(new StoreNewImage($manager->account(), $this->owner, $final_path)); $files->delete($final_path); return $image; }
/** * @param StoresMedia $owner * @param $type * @param null $size * @return string */ public function getAbstractPath(StoresMedia $owner, $type, $size = null) { if (!$this->isSupportedMediaType($type)) { throw new InvalidArgumentException('Need to pass a proper media type'); } return $this->config->get('media.path') . '/' . $owner->getMediaFolder($type, $size); }