diff --git a/src/Commands/Generators/Views/usermodel.tpl.php b/src/Commands/Generators/Views/usermodel.tpl.php index 8937a2978..0ae3650ff 100644 --- a/src/Commands/Generators/Views/usermodel.tpl.php +++ b/src/Commands/Generators/Views/usermodel.tpl.php @@ -10,6 +10,8 @@ class {class} extends ShieldUserModel { protected function initialize(): void { + parent::initialize(); + $this->allowedFields = [ ...$this->allowedFields, diff --git a/tests/Commands/UserModelGeneratorTest.php b/tests/Commands/UserModelGeneratorTest.php index d7fbfd522..41c539593 100644 --- a/tests/Commands/UserModelGeneratorTest.php +++ b/tests/Commands/UserModelGeneratorTest.php @@ -90,6 +90,7 @@ public function testGenerateUserModel(): void $this->assertStringContainsString('class UserModel extends ShieldUserModel', $contents); $this->assertStringContainsString('use CodeIgniter\Shield\Models\UserModel as ShieldUserModel;', $contents); $this->assertStringContainsString('protected function initialize(): void', $contents); + $this->assertStringContainsString('parent::initialize();', $contents); } public function testGenerateUserModelCustomNamespace(): void