src/Move.php
protected function moveDown($id)
    {
        $model = $this->getModel($id);
        $orderAttrName = $this->positionAttribute;
        $orderDir = SORT_ASC;

        $swapModel = $model::find()
            ->where(['>', $orderAttrName, $model->$orderAttrName])
            ->orderBy([$orderAttrName => $orderDir])
            ->one();

        if ($swapModel) {
            $newOrderNumeric = $swapModel->$orderAttrName;
            $swapModel->$orderAttrName = $model->$orderAttrName;
            $model->$orderAttrName = $newOrderNumeric;
            $swapModel->save() && $model->save();
        }

        return $this->redirect($model);
    }
protected function moveDown($id)
    {
        $model = $this->getModel($id);
        $orderAttrName = $this->positionAttribute;
        $orderDir = SORT_ASC;

        $swapModel = $model::find()
            ->where(['>', $orderAttrName, $model->$orderAttrName])
            ->orderBy([$orderAttrName => $orderDir])
            ->one();

        if ($swapModel) {
            $newOrderNumeric = $swapModel->$orderAttrName;
            $swapModel->$orderAttrName = $model->$orderAttrName;
            $model->$orderAttrName = $newOrderNumeric;
            $swapModel->save() && $model->save();
        }

        return $this->redirect($model);
    }
protected function moveDown ( $ id ) { $ model = $ this -> getModel ( $ id ) ; $ orderAttrName = $ this -> positionAttribute ; $ orderDir = SORT_ASC ; $ swapModel = $ model :: find ( ) -> where ( [ '>' , $ orderAttrName , $ model -> $ orderAttrName ] ) -> orderBy ( [ $ orderAttrName => $ orderDir ] ) -> one ( ) ; if ( $ swapModel ) { $ newOrderNumeric = $ swapModel -> $ orderAttrName ; $ swapModel -> $ orderAttrName = $ model -> $ orderAttrName ; $ model -> $ orderAttrName = $ newOrderNumeric ; $ swapModel -> save ( ) && $ model -> save ( ) ; } return $ this -> redirect ( $ model ) ; }
Move model to down
@param mixed $id ID of the model to be moved down
@return mixed
@throws \yii\web\NotFoundHttpException
Move model to down