src = $src; $this->alt = $alt; $this->class = $class; $this->width = $width; $this->height = $height; $this->handleCache(); } public function handleCache() { if (!\Cache::has($this->src)) { $image = file_get_contents($this->src); \Cache::put($this->src, $image, 60 * 24 * 7); // 1 week } return \Cache::get($this->src); } public function render(): View { return view('components.cache-image', ['src' => $this->handleCache(), 'alt' => $this->alt, 'class' => $this->class, 'width' => $this->width, 'height' => $this->height]); } }