# Duplicate entities into another model - newEntities just returns empty \[\]

**URL:** <https://discourse.cakephp.org/t/duplicate-entities-into-another-model-newentities-just-returns-empty/7922>\
**Category:** Uncategorized\
**Created:** [June 8, 2020, 9:13pm UTC](https://discourse.cakephp.org/t/duplicate-entities-into-another-model-newentities-just-returns-empty/7922 "2020-06-08T21:13:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![met](https://avatars.discourse-cdn.com/v4/letter/m/3e96dc/32.png) [@met](https://discourse.cakephp.org/u/met)\
**Post date:** [June 8, 2020, 9:13pm UTC](https://discourse.cakephp.org/t/duplicate-entities-into-another-model-newentities-just-returns-empty/7922/1 "2020-06-08T21:13:16Z")

</div>

I am trying to copy some entities from 1 table to another and keep coming up with an empty arrays - it’s when I try and create `newEntities` does it stop working…

```
    $this->loadModel('Originals');
    $this->loadModel('Duplicates');

    $toCopy = $this->Originals->find('all')
    ])->toArray();

    $data = $this->Duplicates->newEntities($toCopy, ['checkExisting' => false]); 
    // $data = [];
    $result = $this->Duplicates->saveMany($data, ['checkExisting' => false]);
    debug($result);
    // $result = []
    exit;

```

I am really struggling to see what’s missing - the only thing I can see is that the `$entities` in `$toCopy` are of type `Original` and not `Duplicate` - do you need to somehow convert the entity?

Also the `repository` is `Original` as well.

This seems like it should be simple but I don’t know what else to look for and empty []s are no good for debugging!

Thanks

---

<div class="post-metadata">

**Author:** ![dreamingmind](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/dreamingmind/32/1857_2.png) [@dreamingmind](https://discourse.cakephp.org/u/dreamingmind)\
**Post date:** [June 8, 2020, 11:16pm UTC](https://discourse.cakephp.org/t/duplicate-entities-into-another-model-newentities-just-returns-empty/7922/2 "2020-06-08T23:16:46Z")

</div>

`newEntities()` wants an array of array data.

So, you need to loop through the array of entity objects ($toCopy) and run `toArray()` on each one to convert it from an entity object to an array.

Then I think `newEntities()` will accept it.
