示例#1
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getStatusPresetValues()
 {
     return $this->hasMany(StatusPresetValues::className(), ['preset_id' => 'id'])->where(['active' => 1])->orderBy(['sort' => SORT_ASC]);
 }
 public function actionSort()
 {
     if (isset($_POST['sort']) && is_array($_POST['sort'])) {
         $i = 0;
         foreach ($_POST['sort'] as $item_id) {
             $block = StatusPresetValues::findOne($item_id);
             $block->sort = $i;
             $block->save();
             $i++;
         }
     }
     echo json_encode(true);
 }