src/Bootstrap/Laravel/Eloquent/EloquentReflection.php
public static function getEloquentReflectionMethod($object, string $method)
    {
        if ($object instanceof Builder) {

            if (method_exists(Model::class, $method)) {
                return new ReflectionMethod(Model::class, $method);
            } elseif (method_exists(Query::class, $method)) {
                return new ReflectionMethod(Query::class, $method);
            }

        } elseif ($object instanceof Model) {

            if (method_exists(Builder::class, $method)) {
                return new ReflectionMethod(Builder::class, $method);
            } elseif (method_exists(Query::class, $method)) {
                return new ReflectionMethod(Query::class, $method);
            }

        }

        // scoping is one of the ways custom methods are magically called.
        if (substr($method, 0, 5) !== "scope") {
            return static::getEloquentReflectionMethod($object, "scope" . ucfirst($method));
        }

        return false;
    }
public static function getEloquentReflectionMethod($object, string $method)
    {
        if ($object instanceof Builder) {

            if (method_exists(Model::class, $method)) {
                return new ReflectionMethod(Model::class, $method);
            } elseif (method_exists(Query::class, $method)) {
                return new ReflectionMethod(Query::class, $method);
            }

        } elseif ($object instanceof Model) {

            if (method_exists(Builder::class, $method)) {
                return new ReflectionMethod(Builder::class, $method);
            } elseif (method_exists(Query::class, $method)) {
                return new ReflectionMethod(Query::class, $method);
            }

        }

        // scoping is one of the ways custom methods are magically called.
        if (substr($method, 0, 5) !== "scope") {
            return static::getEloquentReflectionMethod($object, "scope" . ucfirst($method));
        }

        return false;
    }
Checks Eloquent-specific method resolution methods.

@throws \ReflectionException

@param $object
@param $method
@return bool|\ReflectionMethod