src/MediaTrait.php
public function cloneMedia($media, $clone_storage = false, $clone_attributes = []) {
    $this->media = $media->replicate();
    $this->setup();
    $this->filename_new = basename($media->filename);

    if ($clone_storage) {
      $this->fileExistsRename();
      $this->storageClone();
    }

    $this->media->fill($clone_attributes);
    $this->media->filename = $this->directory_uri . $this->filename_new;

    return $this->media()->save($this->media);
  }
public function cloneMedia($media, $clone_storage = false, $clone_attributes = []) {
    $this->media = $media->replicate();
    $this->setup();
    $this->filename_new = basename($media->filename);

    if ($clone_storage) {
      $this->fileExistsRename();
      $this->storageClone();
    }

    $this->media->fill($clone_attributes);
    $this->media->filename = $this->directory_uri . $this->filename_new;

    return $this->media()->save($this->media);
  }
Clone an existing media item, onto a new model instance.

@param object $media
The old Media that should be cloned to the current instance.
@param bool $storage_clone
Optionally, also copy the file in storage to a new, unique file
@param $clone_attributes
Optionally, override certain attributes on the clone

@return \Devfactory\Media\Models\Media