src/Execution/MutationExecutor.php
protected static function partitionArgsByRelationType(ReflectionClass $modelReflection, Collection $args, string $relationClass): Collection
    {
        return $args->partition(
            function ($value, string $key) use ($modelReflection, $relationClass): bool {
                if (! $modelReflection->hasMethod($key)) {
                    return false;
                }

                $relationMethodCandidate = $modelReflection->getMethod($key);
                if (! $returnType = $relationMethodCandidate->getReturnType()) {
                    return false;
                }

                if (! $returnType instanceof ReflectionNamedType) {
                    return false;
                }

                return $relationClass === $returnType->getName();
            }
        );
    }
protected static function partitionArgsByRelationType(ReflectionClass $modelReflection, Collection $args, string $relationClass): Collection
    {
        return $args->partition(
            function ($value, string $key) use ($modelReflection, $relationClass): bool {
                if (! $modelReflection->hasMethod($key)) {
                    return false;
                }

                $relationMethodCandidate = $modelReflection->getMethod($key);
                if (! $returnType = $relationMethodCandidate->getReturnType()) {
                    return false;
                }

                if (! $returnType instanceof ReflectionNamedType) {
                    return false;
                }

                return $relationClass === $returnType->getName();
            }
        );
    }
protected static function partitionArgsByRelationType ( ReflectionClass $ modelReflection , Collection $ args , string $ relationClass ) : Collection { return $ args -> partition ( function ( $ value , string $ key ) use ( $ modelReflection , $ relationClass ) : bool { if ( ! $ modelReflection -> hasMethod ( $ key ) ) { return false ; } $ relationMethodCandidate = $ modelReflection -> getMethod ( $ key ) ; if ( ! $ returnType = $ relationMethodCandidate -> getReturnType ( ) ) { return false ; } if ( ! $ returnType instanceof ReflectionNamedType ) { return false ; } return $ relationClass === $ returnType -> getName ( ) ; } ) ; }
Extract all the arguments that correspond to a relation of a certain type on the model.

For example, if the args input looks like this:

[
'comments' =>
['foo' => 'Bar'],
'name' => 'Ralf',
]

and the model has a method "comments" that returns a HasMany relationship,
the result will be:
[
[
'comments' =>
['foo' => 'Bar'],
],
[
'name' => 'Ralf',
]
]

@param  \ReflectionClass  $modelReflection
@param  \Illuminate\Support\Collection  $args
@param  string  $relationClass
@return \Illuminate\Support\Collection  [relationshipArgs, remainingArgs]
Extract all the arguments that correspond to a relation of a certain type on the model .