From b924e6afdf8f16aaa14ad162df0e31e83a6d529f Mon Sep 17 00:00:00 2001 From: Dimitris Mpavelas Date: Wed, 20 Sep 2023 10:24:50 +0300 Subject: [PATCH] Fix "Segmentation fault" for model inheritance (#109) * Fix "Segmentation fault" for model inheritance * Fix formatting --- src/Traits/HasSettings.php | 2 +- .../Models/UsersWithParentModelWithField.php | 10 ++++++++ tests/ParentChildSettingsTest.php | 23 +++++++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 tests/Models/UsersWithParentModelWithField.php create mode 100644 tests/ParentChildSettingsTest.php diff --git a/src/Traits/HasSettings.php b/src/Traits/HasSettings.php index f996d77..a6ec688 100644 --- a/src/Traits/HasSettings.php +++ b/src/Traits/HasSettings.php @@ -40,7 +40,7 @@ public function __call($name, $args) return $this->settings(); } - return call_user_func(get_parent_class($this) . '::__call', $name, $args); + return call_user_func(parent::class . '::__call', $name, $args); } abstract public function getSettingsValue(): array; diff --git a/tests/Models/UsersWithParentModelWithField.php b/tests/Models/UsersWithParentModelWithField.php new file mode 100644 index 0000000..103809b --- /dev/null +++ b/tests/Models/UsersWithParentModelWithField.php @@ -0,0 +1,10 @@ +model = UsersWithParentModelWithField::first(); + } + + public function testSettingsForChild() + { + $testArray = ['a' => 'b']; + $this->model->settings = $testArray; + $this->model->save(); + $this->assertEquals($this->model->settings()->all(), $testArray); + } +} \ No newline at end of file