ensure profile

This commit is contained in:
Antonio Ramirez
2017-07-25 22:40:00 +02:00
parent c80ebbfb71
commit 3b1c7758de

View File

@ -90,6 +90,19 @@ class User extends ActiveRecord implements IdentityInterface
return parent::beforeSave($insert); return parent::beforeSave($insert);
} }
/**
* @inheritdoc
*/
public function afterSave($insert, $changedAttributes)
{
parent::afterSave($insert, $changedAttributes);
if ($insert && $this->profile === null) {
$profile = $this->make(Profile::class);
$profile->link('user', $this);
}
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */