src/MediaUploader.php
private function handleDuplicate(Media $model)
    {
        if ($this->filesystem->disk($model->disk)->has($model->getDiskPath())) {
            switch ($this->config['on_duplicate']) {
                case static::ON_DUPLICATE_ERROR:
                    throw FileExistsException::fileExists($model->getDiskPath());
                    break;
                case static::ON_DUPLICATE_REPLACE:
                    $this->deleteExistingMedia($model);
                    break;
                case static::ON_DUPLICATE_UPDATE:
                    $this->deleteExistingFile($model);
                    $model->{$model->getKeyName()} = Media::forPathOnDisk(
                        $model->disk, $model->getDiskPath())
                        ->pluck($model->getKeyName())->first();
                    $model->exists = true;
                    break;
                case static::ON_DUPLICATE_INCREMENT:
                default:
                    $model->filename = $this->generateUniqueFilename($model);
            }
        }
        return $model;
    }
private function handleDuplicate(Media $model)
    {
        if ($this->filesystem->disk($model->disk)->has($model->getDiskPath())) {
            switch ($this->config['on_duplicate']) {
                case static::ON_DUPLICATE_ERROR:
                    throw FileExistsException::fileExists($model->getDiskPath());
                    break;
                case static::ON_DUPLICATE_REPLACE:
                    $this->deleteExistingMedia($model);
                    break;
                case static::ON_DUPLICATE_UPDATE:
                    $this->deleteExistingFile($model);
                    $model->{$model->getKeyName()} = Media::forPathOnDisk(
                        $model->disk, $model->getDiskPath())
                        ->pluck($model->getKeyName())->first();
                    $model->exists = true;
                    break;
                case static::ON_DUPLICATE_INCREMENT:
                default:
                    $model->filename = $this->generateUniqueFilename($model);
            }
        }
        return $model;
    }
private function handleDuplicate ( Media $ model ) { if ( $ this -> filesystem -> disk ( $ model -> disk ) -> has ( $ model -> getDiskPath ( ) ) ) { switch ( $ this -> config [ 'on_duplicate' ] ) { case static :: ON_DUPLICATE_ERROR : throw FileExistsException :: fileExists ( $ model -> getDiskPath ( ) ) ; break ; case static :: ON_DUPLICATE_REPLACE : $ this -> deleteExistingMedia ( $ model ) ; break ; case static :: ON_DUPLICATE_UPDATE : $ this -> deleteExistingFile ( $ model ) ; $ model -> { $ model -> getKeyName ( ) } = Media :: forPathOnDisk ( $ model -> disk , $ model -> getDiskPath ( ) ) -> pluck ( $ model -> getKeyName ( ) ) -> first ( ) ; $ model -> exists = true ; break ; case static :: ON_DUPLICATE_INCREMENT : default : $ model -> filename = $ this -> generateUniqueFilename ( $ model ) ; } } return $ model ; }
Decide what to do about duplicated files.

@param  \Plank\Mediable\Media $model
@return \Plank\Mediable\Media
@throws \Plank\Mediable\Exceptions\MediaUpload\FileExistsException If directory is not writable or file already exists at the destination and on_duplicate is set to 'error'
Decide what to do about duplicated files .