コード例 #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
ファイル: Block.php プロジェクト: rocketyang/hasscms-app
 public function run()
 {
     $block = \hass\area\models\Block::findByIdOrSlug($this->slug);
     $widget = $block["widget"];
     $this->widgetOptions["model"] = $block;
     $result = $widget::widget($this->widgetOptions);
     return $result;
 }
コード例 #3
0
ファイル: Area.php プロジェクト: rocketyang/hasscms-app
 public function getBlocks()
 {
     if (!empty($this->blocks)) {
         $query = Block::find()->where(['block_id' => $this->blocks])->orderBy([new \yii\db\Expression('FIELD (block_id, ' . implode(', ', $this->blocks) . ')')]);
         return $query->all();
     }
     return [];
 }
コード例 #4
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, "更新失败");
     }
 }