protected function hasNullableForeignKeys(Relation $relation, Model $model = null, array $keys = null)
    {
        if (null === $keys) {
            $keys = $this->getForeignKeyNamesForRelation($relation);
        }

        if ( ! count($keys)) return false;

        // Determine the model on which the foreign key is stored

        if (null === $model) {

            if (    $relation instanceof BelongsTo
                ||  $relation instanceof MorphTo
                ||  is_a($relation, '\\Znck\\Eloquent\\Relations\\BelongsToThrough', true)
            ) {
                $model = $this->model;

            } elseif (  $relation instanceof HasOne
                    ||  $relation instanceof HasMany
                    ||  $relation instanceof BelongsToMany
            ) {
                $model = $relation->getRelated();
            }
        }

        if ( ! $model) {
            throw new RuntimeException('No model could be determined for nullable foreign key check');
        }

        $info = $this->getModelInformation($model);

        // We can use the information to determine whether the model has nullable foreign key
        if ($info) {

            // For all relations, the first key value must be checked
            $attribute = array_get($info->attributes, $this->normalizeForeignKey(head($keys)));
            $nullable  = $attribute ? $attribute->nullable : false;

            // For morph relation types, we must also check the type column
            if (    $nullable
                &&  count($keys) > 1
                &&  (   $relation instanceof MorphTo
                    ||  $relation instanceof MorphOne
                    ||  $relation instanceof MorphMany
                    )
            ) {
                $attribute = array_get($info->attributes, $this->normalizeForeignKey(array_values($keys)[1]));
                $nullable  = $attribute ? $attribute->nullable : false;
            }

            return $nullable;
        }

        // We must somehow determine whether the foreign key is nullable on this
        // model without having information about it.

        // todo: for now, assume false, use the 'nullable_keys' option to configure this instead

        return false;
    }