protected function afterMergeWith(\GO\Base\Db\ActiveRecord $model) { //move company employees to this model too. if ($model->className() == $this->className()) { $stmt = $model->contacts(); while ($contact = $stmt->fetch()) { $contact->company_id = $this->id; $contact->save(); } } return parent::afterMergeWith($model); }