diff --git a/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php b/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php index 8daf2d95c7ba..8833cb42b7d0 100644 --- a/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php +++ b/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php @@ -571,8 +571,7 @@ public function hasAttributeGetMutator($key) return static::$attributeMutatorCache[get_class($this)][$key] = $returnType && $returnType instanceof ReflectionNamedType && - $returnType->getName() === Attribute::class && - is_callable($this->{$method}()->get); + $returnType->getName() === Attribute::class; } /** @@ -949,8 +948,7 @@ public function hasAttributeSetMutator($key) return static::$setAttributeMutatorCache[$class][$key] = $returnType && $returnType instanceof ReflectionNamedType && - $returnType->getName() === Attribute::class && - is_callable($this->{$method}()->set); + $returnType->getName() === Attribute::class; } /** diff --git a/tests/Integration/Database/DatabaseEloquentModelAttributeCastingTest.php b/tests/Integration/Database/DatabaseEloquentModelAttributeCastingTest.php index e666bdafc86a..fc2e8df34c64 100644 --- a/tests/Integration/Database/DatabaseEloquentModelAttributeCastingTest.php +++ b/tests/Integration/Database/DatabaseEloquentModelAttributeCastingTest.php @@ -142,6 +142,8 @@ public function testOneWayCasting() { $model = new TestEloquentModelWithAttributeCast; + $this->assertNull($model->password); + $model->password = 'secret'; $this->assertEquals(hash('sha256', 'secret'), $model->password);