How to upload files to ‘local’ and ‘s3’ storage at the same time
You can move media from one model to another with the move
method.
Moving media
Any conversions defined $anotherModel
will be performed. The name
and the custom_properties
will be transferred as well.
$mediaItem = $model->getMedia()->first();
$movedMediaItem = $mediaItem->move($anotherModel, 'new-collection', 's3');
Copying media
You can also copy media from one model with the copy
method.
$mediaItem = $model->getMedia()->first();
$copiedMediaItem = $mediaItem->copy($anotherModel, 'new-collection', 's3');