src/Generator/Analyzer/Steps/AnalyzeModels.php
protected function prepareModelOverrides()
    {
        $this->overrides = $this->getOverrideConfigForModel($this->moduleId);

        // determine name to use, handle pluralization and check database table override
        if (array_key_exists('name', $this->overrides)) {

            $name = $this->overrides['name'];

        } else {

            $name = array_get($this->module, 'prefixed_name') ?: $this->model['name'];

            if (config('pxlcms.generator.models.model_name.singularize_model_names')) {

                if ($this->context->dutchMode) {
                    $name = $this->dutchSingularize($name);
                } else {
                    $name = str_singular($name);
                }
            }
        }

        // make sure we force set a table name if it does not follow convention
        $tableOverride = null;

        if (str_plural($this->normalizeDb($name)) != $this->normalizeDb($this->module['name'])) {

            $tableOverride = $this->getModuleTablePrefix($this->moduleId)
                           . $this->normalizeDb($this->module['name']);
        }

        // force listified?
        $listified = array_key_exists('listify', $this->overrides)
                   ?    (bool) $this->overrides['listify']
                   :    $this->model['is_listified'];


        // override hidden attributes?
        $this->overrideHidden = [];

        if (    ! is_null(array_get($this->overrides, 'attributes.hidden'))
            &&  ! array_get($this->overrides, 'attributes.hidden-empty')
        ) {
            $this->overrideHidden = array_get($this->overrides, 'attributes.hidden');

            if ( ! is_array($this->overrideHidden)) $this->overrideHidden = [ (string) $this->overrideHidden ];
        }


        // apply overrides to model data
        $this->model['name']         = $name;
        $this->model['table']        = $tableOverride;
        $this->model['is_listified'] = $listified;
        $this->model['hidden']       = $this->overrideHidden;
        $this->model['casts']        = array_get($this->overrides, 'attributes.casts', []);
    }
protected function prepareModelOverrides()
    {
        $this->overrides = $this->getOverrideConfigForModel($this->moduleId);

        // determine name to use, handle pluralization and check database table override
        if (array_key_exists('name', $this->overrides)) {

            $name = $this->overrides['name'];

        } else {

            $name = array_get($this->module, 'prefixed_name') ?: $this->model['name'];

            if (config('pxlcms.generator.models.model_name.singularize_model_names')) {

                if ($this->context->dutchMode) {
                    $name = $this->dutchSingularize($name);
                } else {
                    $name = str_singular($name);
                }
            }
        }

        // make sure we force set a table name if it does not follow convention
        $tableOverride = null;

        if (str_plural($this->normalizeDb($name)) != $this->normalizeDb($this->module['name'])) {

            $tableOverride = $this->getModuleTablePrefix($this->moduleId)
                           . $this->normalizeDb($this->module['name']);
        }

        // force listified?
        $listified = array_key_exists('listify', $this->overrides)
                   ?    (bool) $this->overrides['listify']
                   :    $this->model['is_listified'];


        // override hidden attributes?
        $this->overrideHidden = [];

        if (    ! is_null(array_get($this->overrides, 'attributes.hidden'))
            &&  ! array_get($this->overrides, 'attributes.hidden-empty')
        ) {
            $this->overrideHidden = array_get($this->overrides, 'attributes.hidden');

            if ( ! is_array($this->overrideHidden)) $this->overrideHidden = [ (string) $this->overrideHidden ];
        }


        // apply overrides to model data
        $this->model['name']         = $name;
        $this->model['table']        = $tableOverride;
        $this->model['is_listified'] = $listified;
        $this->model['hidden']       = $this->overrideHidden;
        $this->model['casts']        = array_get($this->overrides, 'attributes.casts', []);
    }
protected function prepareModelOverrides ( ) { $ this -> overrides = $ this -> getOverrideConfigForModel ( $ this -> moduleId ) ; // determine name to use, handle pluralization and check database table override if ( array_key_exists ( 'name' , $ this -> overrides ) ) { $ name = $ this -> overrides [ 'name' ] ; } else { $ name = array_get ( $ this -> module , 'prefixed_name' ) ? : $ this -> model [ 'name' ] ; if ( config ( 'pxlcms.generator.models.model_name.singularize_model_names' ) ) { if ( $ this -> context -> dutchMode ) { $ name = $ this -> dutchSingularize ( $ name ) ; } else { $ name = str_singular ( $ name ) ; } } } // make sure we force set a table name if it does not follow convention $ tableOverride = null ; if ( str_plural ( $ this -> normalizeDb ( $ name ) ) != $ this -> normalizeDb ( $ this -> module [ 'name' ] ) ) { $ tableOverride = $ this -> getModuleTablePrefix ( $ this -> moduleId ) . $ this -> normalizeDb ( $ this -> module [ 'name' ] ) ; } // force listified? $ listified = array_key_exists ( 'listify' , $ this -> overrides ) ? ( bool ) $ this -> overrides [ 'listify' ] : $ this -> model [ 'is_listified' ] ; // override hidden attributes? $ this -> overrideHidden = [ ] ; if ( ! is_null ( array_get ( $ this -> overrides , 'attributes.hidden' ) ) && ! array_get ( $ this -> overrides , 'attributes.hidden-empty' ) ) { $ this -> overrideHidden = array_get ( $ this -> overrides , 'attributes.hidden' ) ; if ( ! is_array ( $ this -> overrideHidden ) ) $ this -> overrideHidden = [ ( string ) $ this -> overrideHidden ] ; } // apply overrides to model data $ this -> model [ 'name' ] = $ name ; $ this -> model [ 'table' ] = $ tableOverride ; $ this -> model [ 'is_listified' ] = $ listified ; $ this -> model [ 'hidden' ] = $ this -> overrideHidden ; $ this -> model [ 'casts' ] = array_get ( $ this -> overrides , 'attributes.casts' , [ ] ) ; }
Prepares override cache for current model being assembled
Prepares override cache for current model being assembled