-
Notifications
You must be signed in to change notification settings - Fork 144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to copy one Model1 instance to Model2 instance ? #79
Comments
Set the |
Yes, I knew I can do it, but that's not what I want in fact. I don't want to keep_old_files on model2 because I want them to be deleted I use a workaroud : copying the file with 'copy' before assigning it to 2014-06-17 15:53 GMT+02:00 Travis Bennett [email protected]:
|
You can still use // Temporarily change the attachment config for the given request:
$model2->image->keep_old_files = true;
// Copy the files over
$model2->image=$model1->image->path();
$model2->save();
// If necessary, change the config back once you're done:
$model2->image->keep_old_files = false; |
Great ! Many thanks. 2014-06-18 21:12 GMT+02:00 Travis Bennett [email protected]:
|
Ooops, finaly that's not working... 2014-06-18 22:49 GMT+02:00 Pierre Rigal
|
Als having a similar issues when trying to copy an existing file to a new model. When trying the method above I get an Exception: I also tried this:
However it keeps deleting the original file. I have no clue where it happens, did some debugging inside |
Hi,
How can I copy $model1->image to $model2->image ?
I tryied :
$model2->image=$model1->image->path();
$model2->save();
It succeed but it delete model2 original file, how can I preserve it ?
Thanks,
The text was updated successfully, but these errors were encountered: