media = $media; return $this; } /** * @return $this */ public function setConversion(Conversion $conversion): UrlGenerator { $this->conversion = $conversion; return $this; } /** * @return $this */ public function setPathGenerator(PathGenerator $pathGenerator): UrlGenerator { $this->pathGenerator = $pathGenerator; return $this; } public function getPathRelativeToRoot(): string { if (is_null($this->conversion)) { return $this->pathGenerator->getPath($this->media).($this->media->file_name); } return $this->pathGenerator->getPathForConversions($this->media) .$this->conversion->getConversionFile($this->media); } protected function getDiskName(): string { return $this->conversion === null ? $this->media->disk : $this->media->conversions_disk; } protected function getDisk(): Filesystem { return Storage::disk($this->getDiskName()); } public function versionUrl(string $path = ''): string { if (! $this->config->get('media-library.version_urls')) { return $path; } return "{$path}?v={$this->media->updated_at->timestamp}"; } }