src/Generator/Writer/Model/Steps/StubReplaceScopes.php
protected function getCmsOrderedConfigReplace()
    {
        $orderColumns = $this->data['ordered_by'] ?: [];


        // for now, ignore the ordering if the column to order on is translated
        $translatedOrderColumns = array_intersect(array_keys($orderColumns
        ), $this->data['translated_attributes']);

        if (count($translatedOrderColumns)) {
            foreach ($translatedOrderColumns as $column) {
                unset($orderColumns[ $column ]);
            }
        }

        if ( ! count($orderColumns)) return '';
        

        // we only need to set a config if the scope method is global
        if (config('pxlcms.generator.models.scopes.position_order') !== CmsModelWriter::SCOPE_GLOBAL) return '';


        // align assignment signs by longest attribute
        $longestLength = 0;

        foreach ($orderColumns as $attribute => $direction) {

            if (strlen($attribute) > $longestLength) {
                $longestLength = strlen($attribute);
            }
        }

        $replace = $this->tab() . "protected \$cmsOrderBy = [\n";

        foreach ($orderColumns as $attribute => $direction) {

            $replace .= $this->tab(2)
                . "'" . str_pad($attribute . "'", $longestLength + 1)
                . " => '" . $direction . "',\n";
        }

        $replace .= $this->tab() . "];\n\n";

        return $replace;
    }
protected function getCmsOrderedConfigReplace()
    {
        $orderColumns = $this->data['ordered_by'] ?: [];


        // for now, ignore the ordering if the column to order on is translated
        $translatedOrderColumns = array_intersect(array_keys($orderColumns
        ), $this->data['translated_attributes']);

        if (count($translatedOrderColumns)) {
            foreach ($translatedOrderColumns as $column) {
                unset($orderColumns[ $column ]);
            }
        }

        if ( ! count($orderColumns)) return '';
        

        // we only need to set a config if the scope method is global
        if (config('pxlcms.generator.models.scopes.position_order') !== CmsModelWriter::SCOPE_GLOBAL) return '';


        // align assignment signs by longest attribute
        $longestLength = 0;

        foreach ($orderColumns as $attribute => $direction) {

            if (strlen($attribute) > $longestLength) {
                $longestLength = strlen($attribute);
            }
        }

        $replace = $this->tab() . "protected \$cmsOrderBy = [\n";

        foreach ($orderColumns as $attribute => $direction) {

            $replace .= $this->tab(2)
                . "'" . str_pad($attribute . "'", $longestLength + 1)
                . " => '" . $direction . "',\n";
        }

        $replace .= $this->tab() . "];\n\n";

        return $replace;
    }
protected function getCmsOrderedConfigReplace ( ) { $ orderColumns = $ this -> data [ 'ordered_by' ] ? : [ ] ; // for now, ignore the ordering if the column to order on is translated $ translatedOrderColumns = array_intersect ( array_keys ( $ orderColumns ) , $ this -> data [ 'translated_attributes' ] ) ; if ( count ( $ translatedOrderColumns ) ) { foreach ( $ translatedOrderColumns as $ column ) { unset ( $ orderColumns [ $ column ] ) ; } } if ( ! count ( $ orderColumns ) ) return '' ; // we only need to set a config if the scope method is global if ( config ( 'pxlcms.generator.models.scopes.position_order' ) !== CmsModelWriter :: SCOPE_GLOBAL ) return '' ; // align assignment signs by longest attribute $ longestLength = 0 ; foreach ( $ orderColumns as $ attribute => $ direction ) { if ( strlen ( $ attribute ) > $ longestLength ) { $ longestLength = strlen ( $ attribute ) ; } } $ replace = $ this -> tab ( ) . "protected \$cmsOrderBy = [\n" ; foreach ( $ orderColumns as $ attribute => $ direction ) { $ replace .= $ this -> tab ( 2 ) . "'" . str_pad ( $ attribute . "'" , $ longestLength + 1 ) . " => '" . $ direction . "',\n" ; } $ replace .= $ this -> tab ( ) . "];\n\n" ; return $ replace ; }
Returns the replace required depending on whether the CMS module has
automatic sorting for defined columns

@return string
Returns the replace required depending on whether the CMS module has automatic sorting for defined columns