public function getLabelAttribute($table)
    {
        $possible = [
            0 => 'label',
            1 => 'title',
            2 => 'name',
            3 => 'symbol',
        ];
        $labels = [
            0 => null,
            1 => null,
            2 => null,
            3 => null,
        ];
        $primaryKeys = [];
        foreach ($table->columns as $column) {
            if ($column->isPrimaryKey) {
                $primaryKeys[] = $column->name;
            }
            foreach ($possible as $weight => $possibleLabel) {
                if (!strcasecmp($column->name, $possibleLabel)) {
                    $labels[$weight] = $column->name;
                }
            }
            if ($column->type === 'string') {
                array_push($labels, $column->name);
            }
        }

        if (($primaryKey = reset($primaryKeys)) !== false) {
            array_push($labels, $primaryKey);
        }

        foreach ($table->columns as $column) {
            array_push($labels, $column->name);
        }

        ksort($labels);

        while (($label = array_shift($labels)) !== false) {
            if ($label !== null) {
                return $label;
            }
        }

        return null;
    }
public function getLabelAttribute($table)
    {
        $possible = [
            0 => 'label',
            1 => 'title',
            2 => 'name',
            3 => 'symbol',
        ];
        $labels = [
            0 => null,
            1 => null,
            2 => null,
            3 => null,
        ];
        $primaryKeys = [];
        foreach ($table->columns as $column) {
            if ($column->isPrimaryKey) {
                $primaryKeys[] = $column->name;
            }
            foreach ($possible as $weight => $possibleLabel) {
                if (!strcasecmp($column->name, $possibleLabel)) {
                    $labels[$weight] = $column->name;
                }
            }
            if ($column->type === 'string') {
                array_push($labels, $column->name);
            }
        }

        if (($primaryKey = reset($primaryKeys)) !== false) {
            array_push($labels, $primaryKey);
        }

        foreach ($table->columns as $column) {
            array_push($labels, $column->name);
        }

        ksort($labels);

        while (($label = array_shift($labels)) !== false) {
            if ($label !== null) {
                return $label;
            }
        }

        return null;
    }
public function getLabelAttribute ( $ table ) { $ possible = [ 0 => 'label' , 1 => 'title' , 2 => 'name' , 3 => 'symbol' , ] ; $ labels = [ 0 => null , 1 => null , 2 => null , 3 => null , ] ; $ primaryKeys = [ ] ; foreach ( $ table -> columns as $ column ) { if ( $ column -> isPrimaryKey ) { $ primaryKeys [ ] = $ column -> name ; } foreach ( $ possible as $ weight => $ possibleLabel ) { if ( ! strcasecmp ( $ column -> name , $ possibleLabel ) ) { $ labels [ $ weight ] = $ column -> name ; } } if ( $ column -> type === 'string' ) { array_push ( $ labels , $ column -> name ) ; } } if ( ( $ primaryKey = reset ( $ primaryKeys ) ) !== false ) { array_push ( $ labels , $ primaryKey ) ; } foreach ( $ table -> columns as $ column ) { array_push ( $ labels , $ column -> name ) ; } ksort ( $ labels ) ; while ( ( $ label = array_shift ( $ labels ) ) !== false ) { if ( $ label !== null ) { return $ label ; } } return null ; }
Finds the label attribute.
@param \yii\db\TableSchema $table the table schema
@return string name of the label attribute
Finds the label attribute .