addBehavior( new SoftDelete([ 'field' => 'deleted', 'value' => 1, ]) ); } public function beforeCreate() { $this->create_time = time(); } public function beforeUpdate() { $this->update_time = time(); } public function afterCreate() { $user = new User(); $user->id = $this->id; $user->name = "user_{$this->id}"; if ($user->create() === false) { throw new \RuntimeException('Create User Failed'); } $userBalance = new UserBalance(); $userBalance->user_id = $user->id; if ($userBalance->create() === false) { throw new \RuntimeException('Create User Balance Failed'); } } }