Skip to content

Commit fb67ecc

Browse files
committed
Group resolvers by class
1 parent b52dfa4 commit fb67ecc

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ public function getRelationValue($key)
415415
// If the "attribute" exists as a method on the model, we will just assume
416416
// it is a relationship and will load and return results from the query
417417
// and hydrate the relationship's value on the "relationships" array.
418-
if (method_exists($this, $key) || isset(static::$relationResolvers[$key])) {
418+
if (method_exists($this, $key) || (static::$relationResolvers[static::class][$key] ?? null)) {
419419
return $this->getRelationshipFromMethod($key);
420420
}
421421
}

src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ trait HasRelationships
6161
*/
6262
public static function resolveRelationUsing($name, Closure $callback)
6363
{
64-
static::$relationResolvers[$name] = $callback;
64+
static::$relationResolvers[static::class][$name] = $callback;
6565
}
6666

6767
/**

src/Illuminate/Database/Eloquent/Model.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1725,8 +1725,8 @@ public function __call($method, $parameters)
17251725
return $this->$method(...$parameters);
17261726
}
17271727

1728-
if (isset(static::$relationResolvers[$method])) {
1729-
return static::$relationResolvers[$method]($this);
1728+
if ($resolver = static::$relationResolvers[static::class][$method] ?? null) {
1729+
return $resolver($this);
17301730
}
17311731

17321732
return $this->forwardCallTo($this->newQuery(), $method, $parameters);

0 commit comments

Comments
 (0)