Replace the table name.

@param \stdClass $scaffolderConfig
@param $modelName

@return $this
554941
private function replaceTableName(stdClass $scaffolderConfig, $modelName)
    {
        $tableName = isset($scaffolderConfig->tableName) && !empty($scaffolderConfig->tableName) ? $scaffolderConfig->tableName : $modelName . 's';

        $this->stub = str_replace('{{table_name}}', strtolower($tableName), $this->stub);

        return $this;
    }
182136
public function createTable($tableName, $tableConfig = null)
    {
        if ($this->hasTable($tableName)) {
            throw new RuntimeException("Table with name {$tableName} is exist. Use rewriteTable()");
        }

        return $this->create($tableName, $tableConfig);
    }
796533
public function renameTable($oldTableName, $newTableName)
    {
        $table = $this->getTable($oldTableName);
        $table->_setName($newTableName);

        $this->dropTable($oldTableName);
        $this->_addTable($table);

        return $this;
    }
572116
public function setTableName($tableName)
    {
        if (trim($tableName) == '') {
            $tableName = null;
        }
        $this->tableName = $tableName;

        return $this;
    }
210326
protected function replaceName(&$stub)
    {
        $stub = str_replace('{{Class}}', $this->scaffoldCommandObj->getObjName('Names'), $stub);
        $stub = str_replace('{{class}}', $this->scaffoldCommandObj->getObjName('names'), $stub);
        $stub = str_replace('{{classSingle}}', $this->scaffoldCommandObj->getObjName('name'), $stub);
        $stub = str_replace('{{ClassSingle}}', $this->scaffoldCommandObj->getObjName('Name'), $stub);

        return $this;
    }
31925
public function setControllerName($modelName)
    {
        $name = end(explode('/', $modelName));
        $this->_controllerName = ucfirst(Text::plural(lcfirst($name)));
        return $this;
    }
223449
public function renameTable($name, $newName)
    {
        $tableDiff          = new TableDiff($name);
        $tableDiff->newName = $newName;
        $this->alterTable($tableDiff);
    }
276563
public static function makeFormRequestName($modelName)
    {
        $name = self::getProperCaseFor($modelName, 'request-form-name');
        $case = ucfirst(camel_case($name));

        if (!empty($postFix = Config::getFormRequestNamePostFix())) {
            return str_finish($case, $postFix);
        }

        return $case;
    }
347612
protected function replaceSchema(&$stub)
    {
        $tables = array_merge(
            $this->getSortedSingularTableNames(),
            $this->getSortedTableNames()
        );

        $stub = str_replace(
            ['{{columnOne}}', '{{columnTwo}}', '{{tableOne}}', '{{tableTwo}}'],
            $tables,
            $stub
        );

        return $this;
    }
41069
public function addColumnName($columnName)
    {
        if (!is_string($columnName) || (strlen($columnName) <= 0)) {
            throw SchemaException::invalidIndexColumnName($this->getName());
        }

        $this->columnNames[] = $columnName;
    }
927189
public function getPage( $config = [] ) {

		$modelClass	= static::$modelClass;
		$modelTable	= $this->getModelTable();

		$siteTable = $this->siteService->getModelTable();
		$roleTable = $this->roleService->getModelTable();
		$userTable = $this->userService->getModelTable();

		// Sorting ----------

		$sort = new Sort([
			'attributes' => [
				'id' => [
					'asc' => [ "$modelTable.id" => SORT_ASC ],
					'desc' => [ "$modelTable.id" => SORT_DESC ],
					'default' => SORT_DESC,
					'label' => 'Id'
				],
	            'site' => [
	                'asc' => [ "$siteTable.name" => SORT_ASC ],
	                'desc' => [ "$siteTable.name" => SORT_DESC ],
	                'default' => SORT_DESC,
	                'label' => 'Template'
	            ],
				'role' => [
					'asc' => [ "$roleTable.name" => SORT_ASC ],
					'desc' => [ "$roleTable.name" => SORT_DESC ],
					'default' => SORT_DESC,
					'label' => 'Slug'
				],
				'name' => [
					'asc' => [ "$userTable.name" => SORT_ASC ],
					'desc' => [ "$userTable.name" => SORT_DESC ],
					'default' => SORT_DESC,
					'label' => 'Name'
				],
				'email' => [
					'asc' => [ "$userTable.email" => SORT_ASC ],
					'desc' => [ "$userTable.email" => SORT_DESC ],
					'default' => SORT_DESC,
					'label' => 'Name'
				],
				'pinned' => [
					'asc' => [ "$modelTable.pinned" => SORT_ASC ],
					'desc' => [ "$modelTable.pinned" => SORT_DESC ],
					'default' => SORT_DESC,
					'label' => 'Pinned'
				],
				'featured' => [
					'asc' => [ "$modelTable.featured" => SORT_ASC ],
					'desc' => [ "$modelTable.featured" => SORT_DESC ],
					'default' => SORT_DESC,
					'label' => 'Featured'
				],
				'cdate' => [
					'asc' => [ "$modelTable.createdAt" => SORT_ASC ],
					'desc' => [ "$modelTable.createdAt" => SORT_DESC ],
					'default' => SORT_DESC,
					'label' => 'Created At'
				],
				'udate' => [
					'asc' => [ "$modelTable.updatedAt" => SORT_ASC ],
					'desc' => [ "$modelTable.updatedAt" => SORT_DESC ],
					'default' => SORT_DESC,
					'label' => 'Updated At'
				]
			],
			'defaultOrder' => [
				'id' => SORT_DESC
			]
		]);

		if( !isset( $config[ 'sort' ] ) ) {

			$config[ 'sort' ] = $sort;
		}

		// Query ------------

		if( !isset( $config[ 'query' ] ) ) {

			$config[ 'hasOne' ] = true;
		}

		// Filters ----------

		// Params
		$filter	= Yii::$app->request->getQueryParam( 'model' );

		// Filter - Model
		if( isset( $filter ) ) {

			switch( $filter ) {

				case 'pinned': {

					$config[ 'conditions' ][ "$modelTable.pinned" ] = true;

					break;
				}
				case 'featured': {

					$config[ 'conditions' ][ "$modelTable.featured" ] = true;

					break;
				}
			}
		}

		// Searching --------

		$searchCol	= Yii::$app->request->getQueryParam( 'search' );

		if( isset( $searchCol ) ) {

			$search = [
				'name' => "$modelTable.name",
				'title' => "$modelTable.title",
				'desc' => "$modelTable.description",
				'content' => "$modelTable.content"
			];

			$config[ 'search-col' ] = $search[ $searchCol ];
		}

		// Reporting --------

		$config[ 'report-col' ]	= [
			'name' => "$modelTable.name",
			'title' => "$modelTable.title",
			'desc' => "$modelTable.description",
			'content' => "$modelTable.content",
			'status' => "$modelTable.status",
			'visibility' => "$modelTable.visibility",
			'order' => "$modelTable.order",
			'pinned' => "$modelTable.pinned",
			'featured' => "$modelTable.featured"
		];

		// Result -----------

		return parent::getPage( $config );
	}
824624
public static function belongsTo($modelClass, $columnName, $options = []) {
        $options['type'] = self::BELONGS_TO;
        $options['modelClass'] = $modelClass;
        $options['compares'] = [[(false === strpos($columnName, '.')) ? "t.$columnName" : $columnName, "r." . $modelClass::getDb()->getTablePk($modelClass::getTableName()), "="]];
        return new self($options);
    }
25722
private function setAppName(stdClass $scaffolderConfig)
    {
        $this->stub = str_replace('{{app_name}}', $scaffolderConfig->name, $this->stub);

        return $this;
    }
405089
private function getDestinationPath($configPath, $modelName = null, $frontend = false)
    {
        $path = $frontend ? '' : $this->folder . DIRECTORY_SEPARATOR;
        $path = $path . config('scaffold.templates.' . $configPath)[1];
        $path = Utils::fillTemplate([
            'MODEL_NAME'  => $modelName,
            'MODULE_NAME' => $this->starter->getModuleName()
        ], $path);
        return $path;
    }
667258
public function compileGroup($stub, $compiledRoutes, stdClass $scaffolderConfig)
    {
        $this->stub = $stub;

        $this->replaceRoutes($compiledRoutes)
            ->replacePrefix($scaffolderConfig->routing->prefix)
            ->store(null, $scaffolderConfig, $this->stub, new FileToCompile(null, null));

        return $this->stub;
    }
1291209
protected function replaceClassName(&$stub)
    {

        $className = $this->scaffoldCommandObj->getObjName('Name') . 'Controller';
        $stub = str_replace('{{class}}', $className, $stub);

        return $this;
    }
143460
public function RenameColumn($OldName, $NewName, $TableName = '') {
      if ($TableName != '')
         $this->_TableName = $TableName;

      // Get the schema for this table
      $OldPrefix = $this->Database->DatabasePrefix;
      $this->Database->DatabasePrefix = $this->_DatabasePrefix;
      $Schema = $this->Database->SQL()->FetchTableSchema($this->_TableName);
      $this->Database->DatabasePrefix = $OldPrefix;

      // Get the definition for this column
      $OldColumn = ArrayValue($OldName, $Schema);
      $NewColumn = ArrayValue($NewName, $Schema);

      // Make sure that one column, or the other exists
      if (!$OldColumn && !$NewColumn)
         throw new Exception(sprintf(T('The `%1$s` column does not exist.'),$OldName));

      // Make sure the new column name isn't already taken
      if ($OldColumn && $NewColumn)
         throw new Exception(sprintf(T('You cannot rename the `%1$s` column to `%2$s` because that column already exists.'), $OldName, $NewName));

      // Rename the column
      // The syntax for renaming a column is:
      // ALTER TABLE tablename CHANGE COLUMN oldname newname originaldefinition;
      if (!$this->Query('alter table `'.$this->_TableName.'` change column `'.$OldName.'` `'.$NewName.'` '.$this->_DefineColumn($OldColumn)))
         throw new Exception(sprintf(T('Failed to rename table `%1$s` to `%2$s`.'), $OldName, $NewName));

      return TRUE;
   }