Back to Laravel Medialibrary

Moving media

docs/advanced-usage/moving-media.md

11.22.1542 B
Original Source

You can move media from one model to another with the move method.

php
$mediaItem = $model->getMedia()->first();

$movedMediaItem = $mediaItem->move($anotherModel, 'new-collection', 's3');

Any conversions defined on $anotherModel will be performed. The name and the custom_properties will be transferred as well.

Copying media

You can also copy media from one model with the copy method.

php
$mediaItem = $model->getMedia()->first();

$copiedMediaItem = $mediaItem->copy($anotherModel, 'new-collection', 's3');