public function getNgRestConfig()
    {
        if ($this->_config == null) {
            $config = new Config();
            
            // Generate config builder object
            $configBuilder = new ConfigBuilder(static::class);
            $this->ngRestConfig($configBuilder);
            $config->setConfig($configBuilder->getConfig());
            foreach ($this->i18n as $fieldName) {
                $config->appendFieldOption($fieldName, 'i18n', true);
            }

            // copy model data into config
            $config->setApiEndpoint(static::ngRestApiEndpoint());
            $config->setPrimaryKey($this->getNgRestPrimaryKey());
            $config->setFilters($this->ngRestFilters());
            $config->setDefaultOrder($this->ngRestListOrder());
            $config->setAttributeGroups($this->ngRestAttributeGroups());
            $config->setGroupByField($this->ngRestGroupByField());
            $config->setGroupByExpanded($this->ngRestGroupByExpanded());
            $config->setTableName($this->tableName());
            $config->setAttributeLabels($this->attributeLabels());
            $config->setActiveButtons($this->ngRestActiveButtons());
            
            // ensure relations are made not on composite table.
            if ($this->ngRestRelations() && count($this->getNgRestPrimaryKey()) > 1) {
                throw new InvalidConfigException("You can not use the ngRestRelations() on composite key model.");
            }
            
            // generate relations
            foreach ($this->generateNgRestRelations() as $relation) {
                $config->setRelation($relation);
            }

            $config->onFinish();
            $this->_config = $config;
        }

        return $this->_config;
    }