src/gii/auth/Generator.php
/**
     * Returns the message to be displayed when the newly generated code is saved successfully.
     * Child classes may override this method to customize the message.
     * @return string the message to be displayed when the newly generated code is saved successfully.
     */
Returns the message to be displayed when the newly generated code is saved successfully.
Child classes may override this method to customize the message.
@return string the message to be displayed when the newly generated code is saved successfully.
Returns the message to be displayed when the newly generated code is saved successfully . Child classes may override this method to customize the message . @return string the message to be displayed when the newly generated code is saved successfully .
public function successMessage()
    {
        $returnMsgA[] = 'The code has been generated successfully.';
        $database = \Yii::$app->db->createCommand("SELECT DATABASE()")->queryScalar();
        $addFieldsA[] = 'api_token';
        $addFieldsA[] = 'allowance';
        $addFieldsA[] = 'allowance_updated_at';
        $userNameFieldGroup = [];
        if ($this->userNameFieldGroup1) {
            $addFieldsA[] = $this->userNameFieldGroup1;
            $userNameFieldGroup[] = $this->userNameFieldGroup1;
        }
        if ($this->userNameFieldGroup2) {
            $addFieldsA[] = $this->userNameFieldGroup2;
            $userNameFieldGroup[] = $this->userNameFieldGroup2;
        }
        if ($this->userNameFieldGroup3) {
            $addFieldsA[] = $this->userNameFieldGroup3;
            $userNameFieldGroup[] = $this->userNameFieldGroup3;
        }
        foreach ($addFieldsA as $k => $v) {
            $query = "
                SELECT
                    1
                FROM
                    information_schema.COLUMNS
                WHERE
                    TABLE_SCHEMA = '$database'
                AND table_name = '$this->tableName'
                AND column_name = '$v'
            ";
            $result = \Yii::$app->db->createCommand($query)->queryAll();
            if (!count($result)) {
                if (in_array($v, ['allowance', 'allowance_updated_at'])) {
                    $sql = "ALTER TABLE $this->tableName ADD $v INT (11)";
                } else {
                    $sql = "ALTER TABLE $this->tableName ADD $v VARCHAR (255)";
                }
                \Yii::$app->db->createCommand($sql)->execute();
                $returnMsgA[] = sprintf('Add column "%s" to "%s"', $v, $this->tableName);
            } else {
                $returnMsgA[] = sprintf('Field "%s" already exists in table "%s"', $v, $this->tableName);
            }
            if (in_array($v, $userNameFieldGroup)) {
                $indexName = $this->tableName . '_' . $v;
                $queryIndex = "
                    SELECT
                        1
                    FROM
                        information_schema.statistics
                    WHERE
                        table_schema = '$database'
                    AND table_name = '$this->tableName'
                    AND index_name = '$indexName'
                ";
                $resultIndex = \Yii::$app->db->createCommand($queryIndex)->queryAll();
                if (!count($resultIndex)) {
                    $sqlu = "ALTER TABLE $this->tableName ADD UNIQUE $indexName( $v )";
                    \Yii::$app->db->createCommand($sqlu)->execute();
                }
            }
        }
        return implode("<br>", $returnMsgA);
    }
public function successMessage ( ) { $ returnMsgA [ ] = 'The code has been generated successfully.' ; $ database = \ Yii :: $ app -> db -> createCommand ( " SELECT DATABASE() " ) -> queryScalar ( ) ; $ addFieldsA [ ] = 'api_token' ; $ addFieldsA [ ] = 'allowance' ; $ addFieldsA [ ] = 'allowance_updated_at' ; $ userNameFieldGroup = [ ] ; if ( $ this -> userNameFieldGroup1 ) { $ addFieldsA [ ] = $ this -> userNameFieldGroup1 ; $ userNameFieldGroup [ ] = $ this -> userNameFieldGroup1 ; } if ( $ this -> userNameFieldGroup2 ) { $ addFieldsA [ ] = $ this -> userNameFieldGroup2 ; $ userNameFieldGroup [ ] = $ this -> userNameFieldGroup2 ; } if ( $ this -> userNameFieldGroup3 ) { $ addFieldsA [ ] = $ this -> userNameFieldGroup3 ; $ userNameFieldGroup [ ] = $ this -> userNameFieldGroup3 ; } foreach ( $ addFieldsA as $ k => $ v ) { $ query = " 
                SELECT
                    1
                FROM
                    information_schema.COLUMNS
                WHERE
                    TABLE_SCHEMA = ' $ database '
                AND table_name = ' $ this -> tableName '
                AND column_name = ' $ v '
             " ; $ result = \ Yii :: $ app -> db -> createCommand ( $ query ) -> queryAll ( ) ; if ( ! count ( $ result ) ) { if ( in_array ( $ v , [ 'allowance' , 'allowance_updated_at' ] ) ) { $ sql = " ALTER TABLE  $ this -> tableName  ADD  $ v  INT (11) " ; } else { $ sql = " ALTER TABLE  $ this -> tableName  ADD  $ v  VARCHAR (255) " ; } \ Yii :: $ app -> db -> createCommand ( $ sql ) -> execute ( ) ; $ returnMsgA [ ] = sprintf ( 'Add column "%s" to "%s"' , $ v , $ this -> tableName ) ; } else { $ returnMsgA [ ] = sprintf ( 'Field "%s" already exists in table "%s"' , $ v , $ this -> tableName ) ; } if ( in_array ( $ v , $ userNameFieldGroup ) ) { $ indexName = $ this -> tableName . '_' . $ v ; $ queryIndex = " 
                    SELECT
                        1
                    FROM
                        information_schema.statistics
                    WHERE
                        table_schema = ' $ database '
                    AND table_name = ' $ this -> tableName '
                    AND index_name = ' $ indexName '
                 " ; $ resultIndex = \ Yii :: $ app -> db -> createCommand ( $ queryIndex ) -> queryAll ( ) ; if ( ! count ( $ resultIndex ) ) { $ sqlu = " ALTER TABLE  $ this -> tableName  ADD UNIQUE  $ indexName (  $ v  ) " ; \ Yii :: $ app -> db -> createCommand ( $ sqlu ) -> execute ( ) ; } } } return implode ( " <br> " , $ returnMsgA ) ; }
Returns the message to be displayed when the newly generated code is saved successfully.
Returns the message to be displayed when the newly generated code is saved successfully .