Skip to content

Commit b924e6a

Browse files
authored
Fix "Segmentation fault" for model inheritance (#109)
* Fix "Segmentation fault" for model inheritance * Fix formatting
1 parent 2fe95e4 commit b924e6a

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

src/Traits/HasSettings.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function __call($name, $args)
4040
return $this->settings();
4141
}
4242

43-
return call_user_func(get_parent_class($this) . '::__call', $name, $args);
43+
return call_user_func(parent::class . '::__call', $name, $args);
4444
}
4545

4646
abstract public function getSettingsValue(): array;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace Glorand\Model\Settings\Tests\Models;
4+
5+
class UsersWithParentModelWithField extends UserWithTextField
6+
{
7+
protected $table = 'users_with_field';
8+
9+
protected $fillable = ['id', 'name'];
10+
}

tests/ParentChildSettingsTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace Glorand\Model\Settings\Tests;
4+
5+
use Glorand\Model\Settings\Tests\Models\UsersWithParentModelWithField;
6+
use Glorand\Model\Settings\Tests\Models\UserWithField as User;
7+
8+
class ParentChildSettingsTest extends TestCase
9+
{
10+
public function setUp(): void
11+
{
12+
parent::setUp();
13+
$this->model = UsersWithParentModelWithField::first();
14+
}
15+
16+
public function testSettingsForChild()
17+
{
18+
$testArray = ['a' => 'b'];
19+
$this->model->settings = $testArray;
20+
$this->model->save();
21+
$this->assertEquals($this->model->settings()->all(), $testArray);
22+
}
23+
}

0 commit comments

Comments
 (0)