public function getAllFieldsetsAttribute()
    {
        $fieldsets = [];
        $all_fieldsets = [];

        if ($this->type->fieldsets)
            $all_fieldsets = $this->type->fieldsets;
        if ($this->fieldsets)
            $all_fieldsets = $all_fieldsets->merge($this->fieldsets);

        if ($all_fieldsets) {
            foreach ($all_fieldsets as $fieldset) {
                $fieldset_orig = clone $fieldset;
                $fieldset_repetitions = [$fieldset_orig];

                foreach ($fieldset->fields as $field) {
                    $field_orig = clone $field;
                    $field_repetitions = [$field_orig];

                    $field_values = [];
                    $values = ContentFieldData::query()->where('content_id', $this->id)->where('field_id', $field->id)->get();

                    if ($values) {
                        foreach ($values as $valueData) {
                            if (@unserialize($valueData->value) !== false || $valueData->value == 'b:0;')
                                $valueData->value = unserialize($valueData->value);

                            if (!isset($fieldset_repetitions[$valueData->fieldset_repetition_key]))
                                $fieldset_repetitions[$valueData->fieldset_repetition_key] = clone $fieldset_orig;
                            if (!isset($field_repetitions[$valueData->field_repetition_key]))
                                $field_repetitions[$valueData->field_repetition_key] = clone $field_orig;

                            $field_values[$valueData->fieldset_repetition_key][$valueData->field_repetition_key] = $valueData->value;
                        }
                    }
                    $field->value = $field_values;
                    $field->repetitions = $field_repetitions;
                }

                $fieldset->repetitions = $fieldset_repetitions;
                $fieldsets[] = $fieldset;
            }

        }

        return $fieldsets;
    }