-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Respect Laravel's new accessors #2394
Conversation
Fix getting a value from a one-word `\Illuminate\Database\Eloquent\Casts\Attribute`-returning accessors
Codecov Report
@@ Coverage Diff @@
## master #2394 +/- ##
============================================
+ Coverage 87.62% 87.63% +0.01%
- Complexity 676 677 +1
============================================
Files 31 31
Lines 1551 1553 +2
============================================
+ Hits 1359 1361 +2
Misses 192 192
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Whats the status of this PR? |
I've managed to fix the issue, but the cs-fixer denied my code for some reason. As the code in |
This is a breaking change and is this related to embedded relation? |
@divine this change isn't specifically related to an embedded relation as this case may also happen when using other types of relations. I'm not sure if it's really a breaking change because all this code does is performs an additional check whether requested attribute returns an |
@@ -155,8 +155,12 @@ public function getAttribute($key) | |||
} | |||
|
|||
// This checks for embedded relation support. | |||
if (method_exists($this, $key) && ! method_exists(self::class, $key)) { | |||
return $this->getRelationValue($key); | |||
if ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if ( | |
if ( | |
method_exists($this, $key) | |
&& !method_exists(self::class, $key) | |
&& !$this->hasAttributeGetMutator($key) | |
) { | |
return $this->getRelationValue($key); |
This should fix your formatting so that PHP-CS-Fixer passes
Closed in favor of #2438. |
Fix getting a value from
\Illuminate\Database\Eloquent\Casts\Attribute
-returning accessors (issue #2363).