- Added a new clone() method to Repository() base class

This commit is contained in:
mcndave committed 2023-10-30 19:41:40 +00:00
1 parent cc741566fb
commit c9d9281c63
2 files changed
+10 -1

No files matched your search

+9
View File
@@ -144,6 +144,15 @@ class Repository
}
}
public function clone(object|array $entity) : bool
{
foreach(Ulmus::resolveEntity($this->entityClass)->getPrimaryKeyField() as $key => $field) {
unset($entity->$key);
}
return $this->save($entity);
}
public function save(object|array $entity, ? array $fieldsAndValue = null, bool $replace = false) : bool
{
if ( is_array($entity) ) {