/** * @return DB */ public function add(AbstractModel $model) { if ($this->identityMap->hasIdentityKey($model)) { $model = $this->identityMap->get($model); } else { $this->new->attach($model); } $this->attach($model); return $this; }