From 4182fde47b378a2bf9f60e0dbf7be916d0a44b58 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Dadashi Date: Tue, 14 Mar 2023 12:10:55 +0330 Subject: [PATCH] fix: add `parent::initialize()` for access the table name --- src/Commands/Generators/Views/usermodel.tpl.php | 2 ++ tests/Commands/UserModelGeneratorTest.php | 1 + 2 files changed, 3 insertions(+) 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