CTOlet / yii2-attachments

Yii2 extension for uploading and attaching the files to the models
66 stars 57 forks source link

How to copy (duplicate) attachments from one model to another? #74

Open kwazaro opened 5 years ago

kwazaro commented 5 years ago

I have model with attachments:

$model = Page::findOne($id);

I want to duplicate this model and all it's attachments:

$newModel = new Page();
$newModel->setAttributes($model->attributes);
$newModel->save();

How to deal with attachments here?