/** * Execute the job. */ public function handle() { /** * Create Extra * @var Extra $extra */ $this->extra->update($this->data); $aspectDir = @$this->data['aspect_ratio'] ?: '16x9'; /** * Move Extra Content to folder */ $path = '/image/products-extras/'; $productCode = $this->product->getAttribute('code'); if ($this->image) { $imageName = $productCode . '-extra-image-' . $this->extra->id . '.' . $this->image->guessExtension(); $this->image->move(base_path() . $path, $imageName); $this->extra->setAttribute('image', $path . $imageName); } if ($this->video) { $videoName = $productCode . '-extra-video-' . $this->extra->id . '.' . $this->video->guessExtension(); $this->video->move(base_path() . $path . $aspectDir . '/', $videoName); $this->extra->setAttribute('video', $videoName); } $this->extra->save(); /** * Announce ExtraWasUpdated */ event(new ExtraWasUpdated($this->extra)); }