src/Generator/Writer/Model/Steps/StubReplaceAttributeData.php
protected function getDefaultsReplace()
    {
        if ( ! config('pxlcms.generator.models.include_defaults')) return '';

        $attributes = $this->data['defaults'] ?: [];

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

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

        foreach ($attributes as $attribute => $default) {

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

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

        foreach ($attributes as $attribute => $default) {

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

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

        return $replace;
    }
protected function getDefaultsReplace()
    {
        if ( ! config('pxlcms.generator.models.include_defaults')) return '';

        $attributes = $this->data['defaults'] ?: [];

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

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

        foreach ($attributes as $attribute => $default) {

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

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

        foreach ($attributes as $attribute => $default) {

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

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

        return $replace;
    }
protected function getDefaultsReplace ( ) { if ( ! config ( 'pxlcms.generator.models.include_defaults' ) ) return '' ; $ attributes = $ this -> data [ 'defaults' ] ? : [ ] ; if ( ! count ( $ attributes ) ) return '' ; // align assignment signs by longest attribute $ longestLength = 0 ; foreach ( $ attributes as $ attribute => $ default ) { if ( strlen ( $ attribute ) > $ longestLength ) { $ longestLength = strlen ( $ attribute ) ; } } $ replace = $ this -> tab ( ) . "protected \$attributes = [\n" ; foreach ( $ attributes as $ attribute => $ default ) { $ replace .= $ this -> tab ( 2 ) . "'" . str_pad ( $ attribute . "'" , $ longestLength + 1 ) . " => " . $ default . ",\n" ; } $ replace .= $ this -> tab ( ) . "];\n\n" ; return $ replace ; }
Returns the replacement for the default attributes placeholder

@return string
Returns the replacement for the default attributes placeholder