Пример #1
0
 protected function findModel($id)
 {
     if (($model = Block::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Пример #2
0
 public function actionUpdateBlocksCreate()
 {
     $id = \Yii::$app->getRequest()->post("id");
     $blocks = \Yii::$app->getRequest()->post("blocks");
     $block = \Yii::$app->getRequest()->post("block");
     $model = $this->findModel($id);
     $model->blocks = $blocks;
     $block = Block::findOne($block);
     $block->used = BooleanEnum::TRUE;
     if ($model->save() && $block->save()) {
         return $this->renderJsonMessage(true, "更新成功");
     } else {
         return $this->renderJsonMessage(true, "更新失败");
     }
 }