public function replaceAsset($replace, $with)
    {
        $old = $this->assets()->findOrFail($replace);

        $this->assets()->detach($old->id);
        $old->delete();

        $this->addFile(Asset::findOrFail($with), $old->pivot->type, $old->pivot->locale);
    }
public function replaceAsset($replace, $with)
    {
        $old = $this->assets()->findOrFail($replace);

        $this->assets()->detach($old->id);
        $old->delete();

        $this->addFile(Asset::findOrFail($with), $old->pivot->type, $old->pivot->locale);
    }
public function replaceAsset ( $ replace , $ with ) { $ old = $ this -> assets ( ) -> findOrFail ( $ replace ) ; $ this -> assets ( ) -> detach ( $ old -> id ) ; $ old -> delete ( ) ; $ this -> addFile ( Asset :: findOrFail ( $ with ) , $ old -> pivot -> type , $ old -> pivot -> locale ) ; }
Remove the asset and attaches a new one.

@param $replace
@param $with
@throws \Spatie\MediaLibrary\Exceptions\FileCannotBeAdded
@throws \Thinktomorrow\AssetLibrary\Exceptions\AssetUploadException
Remove the asset and attaches a new one .