public function actionView($slug) { $this->layout = 'singlepage'; $game = Game::findOne(['slug' => $slug]); if (!$game) { throw new NotFoundHttpException('您请求的页面不存在!'); } //myVarDump($game); return $this->render('view', ['model' => $game]); }
/** * Finds the Game model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Game the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Game::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
?> ">首页</a></li> <li class="active">充值中心</li> </ul> </div> </div> <?php $this->endBlock(); ?> <div class="container content"> <div class="row"> <div class="col-md-12"> <div class="headline"><h3 class="heading-sm">确认充值信息</h3></div> <?php echo DetailView::widget(['model' => $model, 'attributes' => ['user_id', ['attribute' => 'game_id', 'value' => \common\models\Game::findOne($model->game_id)['name']], ['attribute' => 'server_id', 'value' => \common\models\GameServer::findOne($model->server_id)['server_name']], 'pay_mode', ['attribute' => 'amount', 'value' => $model->amount . '元'], ['attribute' => '获得元宝数量', 'value' => $model->amount * 10 . '元宝']]]); ?> <?php $form = \kartik\form\ActiveForm::begin(['type' => \kartik\form\ActiveForm::TYPE_HORIZONTAL]); ?> <?php echo $form->field($model, 'user_id')->textInput(['value' => Yii::$app->user->identity->username, 'readonly' => 'readonly']); ?> <?php echo $form->field($model, 'game_id')->dropDownList(ArrayHelper::map(\common\models\Game::find()->statusInUse()->all(), 'id', 'name'), ['prompt' => '']); ?> <?php echo $form->field($model, 'server_id')->dropDownList(ArrayHelper::map(\common\models\GameServer::find()->statusInUse()->all(), 'id', 'server_name'), ['prompt' => '']);