I am using Moloquent and I want to create a new document from an existing document and save it by updating some fields of it.
For example, I have:
$originalObject = $this->someModel->find('someId');
$clonedObject = clone $originalObject;
$clonedObject->someField = 'Some Value';
$clonedObject->save()
But it removes the originaObject and just creates the new object only. I thought that the _id might be causing the issue so I also tried unset($clonedObject->_id) but still I am not able to achieve the desired result.
Can anyone please tell me how can I go about cloning an existing document into a new document?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire