diff --git a/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php b/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php index 67e44605eb4c..3fa3e9295838 100644 --- a/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php +++ b/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php @@ -2,6 +2,7 @@ namespace Illuminate\Database\Eloquent\Concerns; +use BadMethodCallException; use Carbon\CarbonImmutable; use Carbon\CarbonInterface; use DateTimeInterface; @@ -609,7 +610,15 @@ public function hasAttributeGetMutator($key) */ protected function mutateAttribute($key, $value) { - return $this->{'get'.Str::studly($key).'Attribute'}($value); + try { + return $this->{'get'.Str::studly($key).'Attribute'}($value); + } catch (BadMethodCallException $exception) { + if (method_exists($this, Str::studly($key)) && $this->{Str::studly($key)}($value) instanceof Attribute) { + return $this->{Str::studly($key)}; + } + + throw $exception; + } } /**