public function moveDownstairs()
    {
        $startIndex = (int)$this->sort_index;
        foreach (self::find()->where('sort_index >= :index', ['index' => $startIndex])->andWhere(['nav_container_id' => $this->nav_container_id, 'parent_nav_id' => $this->parent_nav_id])->orderBy('sort_index ASC')->asArray()->all() as $item) {
            --$startIndex;
            Yii::$app->db->createCommand()->update(self::tableName(), ['sort_index' => $startIndex], 'id=:id', ['id' => $item['id']])->execute();
        }
    }
public function moveDownstairs()
    {
        $startIndex = (int)$this->sort_index;
        foreach (self::find()->where('sort_index >= :index', ['index' => $startIndex])->andWhere(['nav_container_id' => $this->nav_container_id, 'parent_nav_id' => $this->parent_nav_id])->orderBy('sort_index ASC')->asArray()->all() as $item) {
            --$startIndex;
            Yii::$app->db->createCommand()->update(self::tableName(), ['sort_index' => $startIndex], 'id=:id', ['id' => $item['id']])->execute();
        }
    }
public function moveDownstairs ( ) { $ startIndex = ( int ) $ this -> sort_index ; foreach ( self :: find ( ) -> where ( 'sort_index >= :index' , [ 'index' => $ startIndex ] ) -> andWhere ( [ 'nav_container_id' => $ this -> nav_container_id , 'parent_nav_id' => $ this -> parent_nav_id ] ) -> orderBy ( 'sort_index ASC' ) -> asArray ( ) -> all ( ) as $ item ) { -- $ startIndex ; Yii :: $ app -> db -> createCommand ( ) -> update ( self :: tableName ( ) , [ 'sort_index' => $ startIndex ] , 'id=:id' , [ 'id' => $ item [ 'id' ] ] ) -> execute ( ) ; } }
Reduces the sort_index value for all elements where the current sort index is larger or equal.

id|index
--------
1|0
2|1
3|2
4|3

apply moveDownstairs() to id 2 would produce the following output:

id|index
1|0
2|0
3|1
4|2

> This method is therefore only usefull when you want to push the latest item upstairs.
Reduces the sort_index value for all elements where the current sort index is larger or equal .