From c91da08792da5877f72f3408b1499ef5ab3fdfae Mon Sep 17 00:00:00 2001 From: Anthony Clark Date: Fri, 12 Jan 2024 12:10:59 -0800 Subject: [PATCH] Update Duster and fix --- composer.json | 6 ++++- src/HasParent.php | 27 +++++++++---------- ...ablesMergeWithParentModelFillablesTest.php | 2 +- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/composer.json b/composer.json index 879e514..8d38d7f 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ "require-dev": { "orchestra/testbench": "^7.0||^8.0", "phpunit/phpunit": "^9.5.10||^10.0", - "tightenco/duster": "^2.5" + "tightenco/duster": "^2.7" }, "autoload": { "psr-4": { @@ -36,5 +36,9 @@ "Parental\\Tests\\": "tests/", "Database\\Factories\\": "tests/factories/" } + }, + "scripts": { + "lint": "vendor/bin/duster lint", + "fix": "vendor/bin/duster fix" } } diff --git a/src/HasParent.php b/src/HasParent.php index fed9566..6673710 100644 --- a/src/HasParent.php +++ b/src/HasParent.php @@ -119,19 +119,6 @@ public function getClassNameForSerialization(): string return $this->getParentClass(); } - /** - * Get the class name for Parent Class. - * - * @throws ReflectionException - */ - protected function getParentClass(): string - { - static $parentClassName; - - return $parentClassName ?: $parentClassName = (new ReflectionClass($this))->getParentClass()->getName(); - } - - /** * Merge the fillable attributes for the model with those of its Parent Class * @@ -146,7 +133,19 @@ public function getFillable() return $this->fillable; } $parentFillable = (new $parentClass)->getFillable(); - + return array_unique(array_merge($parentFillable, $this->fillable)); } + + /** + * Get the class name for Parent Class. + * + * @throws ReflectionException + */ + protected function getParentClass(): string + { + static $parentClassName; + + return $parentClassName ?: $parentClassName = (new ReflectionClass($this))->getParentClass()->getName(); + } } diff --git a/tests/Features/ChildModelFillablesMergeWithParentModelFillablesTest.php b/tests/Features/ChildModelFillablesMergeWithParentModelFillablesTest.php index c2a3584..10e2f3b 100644 --- a/tests/Features/ChildModelFillablesMergeWithParentModelFillablesTest.php +++ b/tests/Features/ChildModelFillablesMergeWithParentModelFillablesTest.php @@ -9,7 +9,7 @@ class ChildModelFillablesMergeWithParentModelFillablesTest extends TestCase { /** @test */ - function child_fillables_are_merged_with_parent_fillables() + public function child_fillables_are_merged_with_parent_fillables() { $workshop = Workshop::create([ 'name' => 'Scaling Laravel',