protected function parseHeader($relation, $default = false)
    {
        if (false !== $this->header)
        {
            $attributes = explode('.', $this->header);

            foreach ($attributes as $attribute)
            {
                if (isset($relation->{$attribute}))
                {
                    $relation = $relation->{$attribute};
                }
            }
        }

        if (!is_string($relation))
        {
            if ($default !== false)
            {
                return $default;
            }

            return $relation->primaryKey;
        }

        return $relation;
    }