protected function reorder($parentId = 0)
    {
        $query = call_user_func("$this->ownerClassName::find")
            ->select("$this->primaryKey")
            ->orderBy("$this->sortField, $this->primaryKey");
        if ( $this->parentIdField ) {
            $query->where([ $this->parentIdField => $parentId ]);
        }
        $data = array_map('intval', $query->column());
        foreach ( $data as $i => $itemPK ) {
            call_user_func("$this->ownerClassName::updateAll",
                [ $this->sortField => ($i + 1) * 100 ],
                [ $this->primaryKey => $itemPK ]);
        }
    }
protected function reorder($parentId = 0)
    {
        $query = call_user_func("$this->ownerClassName::find")
            ->select("$this->primaryKey")
            ->orderBy("$this->sortField, $this->primaryKey");
        if ( $this->parentIdField ) {
            $query->where([ $this->parentIdField => $parentId ]);
        }
        $data = array_map('intval', $query->column());
        foreach ( $data as $i => $itemPK ) {
            call_user_func("$this->ownerClassName::updateAll",
                [ $this->sortField => ($i + 1) * 100 ],
                [ $this->primaryKey => $itemPK ]);
        }
    }
protected function reorder ( $ parentId = 0 ) { $ query = call_user_func ( "$this->ownerClassName::find" ) -> select ( "$this->primaryKey" ) -> orderBy ( "$this->sortField, $this->primaryKey" ) ; if ( $ this -> parentIdField ) { $ query -> where ( [ $ this -> parentIdField => $ parentId ] ) ; } $ data = array_map ( 'intval' , $ query -> column ( ) ) ; foreach ( $ data as $ i => $ itemPK ) { call_user_func ( "$this->ownerClassName::updateAll" , [ $ this -> sortField => ( $ i + 1 ) * 100 ] , [ $ this -> primaryKey => $ itemPK ] ) ; } }
Reordering models when no more exist free indexes
@param integer $parentId Reorder child items of this parent
Reordering models when no more exist free indexes