+ /**
+ * Update the image file of an existing image in the system.
+ * @throws ImageUploadException
+ */
+ public function updateImageFile(Image $image, UploadedFile $file): void
+ {
+ if ($file->getClientOriginalExtension() !== pathinfo($image->path, PATHINFO_EXTENSION)) {
+ throw new ImageUploadException(trans('errors.image_upload_replace_type'));
+ }
+
+ $image->refresh();
+ $image->updated_by = user()->id;
+ $image->touch();
+ $image->save();
+ $this->imageService->replaceExistingFromUpload($image->path, $image->type, $file);
+ $this->loadThumbs($image, true);
+ }
+