protected function transformKeysCase(array $transformed)
    {
        // Get the config for how many levels of keys to transform
        $levels = config('api.formatsOptions.transform_keys_levels', null);

        /**
         * Transform all keys to required case, to the specified number of levels (by default, infinite)
         */
        $transformed = $this->formatKeyCase($transformed, $levels);

        /*
         * However, if the level is 1, we also want to transform the first level of keys in a json field which has been cast to array
         */
        if ($levels == 1 && ! is_null($this->model)) {
            foreach ($this->model->getCasts() as $fieldName => $castType) {
                if ($castType == 'array') {
                    $fieldNameFormatted = $this->formatKeyCase($fieldName);
                    if (array_key_exists($fieldNameFormatted, $transformed)) {
                        $transformed[$fieldNameFormatted] = $this->formatKeyCase($transformed[$fieldNameFormatted]);
                    }
                }
            }
        }

        return $transformed;
    }
protected function transformKeysCase(array $transformed)
    {
        // Get the config for how many levels of keys to transform
        $levels = config('api.formatsOptions.transform_keys_levels', null);

        /**
         * Transform all keys to required case, to the specified number of levels (by default, infinite)
         */
        $transformed = $this->formatKeyCase($transformed, $levels);

        /*
         * However, if the level is 1, we also want to transform the first level of keys in a json field which has been cast to array
         */
        if ($levels == 1 && ! is_null($this->model)) {
            foreach ($this->model->getCasts() as $fieldName => $castType) {
                if ($castType == 'array') {
                    $fieldNameFormatted = $this->formatKeyCase($fieldName);
                    if (array_key_exists($fieldNameFormatted, $transformed)) {
                        $transformed[$fieldNameFormatted] = $this->formatKeyCase($transformed[$fieldNameFormatted]);
                    }
                }
            }
        }

        return $transformed;
    }
protected function transformKeysCase ( array $ transformed ) { // Get the config for how many levels of keys to transform $ levels = config ( 'api.formatsOptions.transform_keys_levels' , null ) ; /**
         * Transform all keys to required case, to the specified number of levels (by default, infinite)
         */ $ transformed = $ this -> formatKeyCase ( $ transformed , $ levels ) ; /*
         * However, if the level is 1, we also want to transform the first level of keys in a json field which has been cast to array
         */ if ( $ levels == 1 && ! is_null ( $ this -> model ) ) { foreach ( $ this -> model -> getCasts ( ) as $ fieldName => $ castType ) { if ( $ castType == 'array' ) { $ fieldNameFormatted = $ this -> formatKeyCase ( $ fieldName ) ; if ( array_key_exists ( $ fieldNameFormatted , $ transformed ) ) { $ transformed [ $ fieldNameFormatted ] = $ this -> formatKeyCase ( $ transformed [ $ fieldNameFormatted ] ) ; } } } } return $ transformed ; }
Transform the keys of the object to the correct case as required

@param array $transformed
@return array $transformed
Transform the keys of the object to the correct case as required