belongsTo(ProductProxy::modelClass()); } /** * Get image url for the file. */ public function file_url() { return Storage::url($this->file); } /** * Get image url for the file. */ public function getFileUrlAttribute() { return $this->file_url(); } /** * @return array */ public function toArray() { $array = parent::toArray(); $translation = $this->translate(core()->getRequestedLocaleCode()); $array['title'] = $translation ? $translation->title : ''; $array['file_url'] = $this->file ? Storage::url($this->file) : null; return $array; } }