public function add($m, $defaults = [])
{
if (isset($defaults[0])) {
$m->table = $defaults[0];
unset($defaults[0]);
}
$m = $this->factory($m, $defaults);
if ($m->persistence) {
if ($m->persistence === $this) {
return $m;
}
throw new Exception(['Model is already related to another persistence']);
}
$m->setDefaults($defaults);
$m->persistence = $this;
$m->persistence_data = [];
$this->initPersistence($m);
$m = $this->_add($m, $defaults);
$this->hook('afterAdd', [$m]);
return $m;
}