@@ -122,30 +122,20 @@ public function getAttribute($key)
122
122
return ;
123
123
}
124
124
125
- // If the attribute exists in the attribute array or has a "get" mutator we will
126
- // get the attribute's value. Otherwise, we will proceed as if the developers
127
- // are asking for a relationship's value. This covers both types of values.
128
- if (array_key_exists ($ key , $ this ->attributes ) ||
129
- array_key_exists ($ key , $ this ->casts ) ||
130
- $ this ->hasGetMutator ($ key ) ||
131
- $ this ->hasAttributeGetMutator ($ key ) ||
132
- $ this ->isClassCastable ($ key )) {
133
- return $ this ->getAttributeValue ($ key );
134
- }
135
-
136
- // Here we will determine if the model base class itself contains this given key
137
- // since we don't want to treat any of those methods as relationships because
138
- // they are all intended as helper methods and none of these are relations.
139
- if (method_exists (self ::class, $ key )) {
140
- return ;
141
- }
142
-
143
125
// Dot notation support.
144
126
if ((Str::contains ($ key , '. ' ) && Arr::has ($ this ->attributes , $ key )) || $ this ->containsCastableField ($ key )) {
145
127
return $ this ->getAttributeValue ($ key );
146
128
}
147
129
148
- return $ this ->getRelationValue ($ key );
130
+ if (
131
+ method_exists ($ this , $ key )
132
+ && ! method_exists (self ::class, $ key )
133
+ && ! $ this ->hasAttributeGetMutator ($ key )
134
+ ) {
135
+ return $ this ->getRelationValue ($ key );
136
+ }
137
+
138
+ return parent ::getAttribute ($ key );
149
139
}
150
140
151
141
/**
0 commit comments