public function eventBeforeInsert()
    {
        $item = self::find()->where([
            'nav_container_id' => $this->nav_container_id,
            'parent_nav_id' => $this->parent_nav_id
        ])->orderBy('sort_index DESC')->limit(1)->asArray()->one();
        if (!$item) {
            $this->sort_index = 1;
        } else {
            $this->sort_index = $item['sort_index'] + 1;
        }
    }
public function eventBeforeInsert()
    {
        $item = self::find()->where([
            'nav_container_id' => $this->nav_container_id,
            'parent_nav_id' => $this->parent_nav_id
        ])->orderBy('sort_index DESC')->limit(1)->asArray()->one();
        if (!$item) {
            $this->sort_index = 1;
        } else {
            $this->sort_index = $item['sort_index'] + 1;
        }
    }
public function eventBeforeInsert ( ) { $ item = self :: find ( ) -> where ( [ 'nav_container_id' => $ this -> nav_container_id , 'parent_nav_id' => $ this -> parent_nav_id ] ) -> orderBy ( 'sort_index DESC' ) -> limit ( 1 ) -> asArray ( ) -> one ( ) ; if ( ! $ item ) { $ this -> sort_index = 1 ; } else { $ this -> sort_index = $ item [ 'sort_index' ] + 1 ; } }
find the latest sort index cms_nav item for the current nav_container_id and parent_nav_id and set internal index count plus one.
find the latest sort index cms_nav item for the current nav_container_id and parent_nav_id and set internal index count plus one .