/** * Updates an existing KefuSelfservice model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed */ public function actionUpdate($id) { $model = $this->findModel($id); $categories = KefuSelfserviceCat::find()->all(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('update', ['model' => $model, 'categories' => $categories]); } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = KefuSelfserviceCat::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'parent_id' => $this->parent_id]); $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'slug', $this->slug]); return $dataProvider; }
/** * @return \yii\db\ActiveQuery */ public function getCategory() { return $this->hasOne(KefuSelfserviceCat::className(), ['id' => 'category_id']); }
<?php // echo $this->render('_search', ['model' => $searchModel]); ?> <?php if (Yii::$app->user->can('administrator')) { ?> <p> <?php echo Html::a(Yii::t('backend', 'Create {modelClass}', ['modelClass' => Yii::t('common', 'Kefu Selfservice')]), ['create'], ['class' => 'btn btn-success']); ?> </p> <?php } ?> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'sn', ['attribute' => 'game_server', 'value' => function ($model) { return \common\models\GameServer::findOne($model->game_server)['server_name']; }, 'filter' => ArrayHelper::map(\common\models\GameServer::find()->all(), 'id', 'server_name')], 'game_role', ['attribute' => 'category_id', 'value' => function ($model) { return $model->category ? $model->category->title : null; }, 'filter' => ArrayHelper::map(\common\models\KefuSelfserviceCat::find()->all(), 'id', 'title')], 'created_at:datetime', ['class' => \common\grid\EnumColumn::className(), 'attribute' => 'status', 'enum' => KefuSelfservice::getStatus()], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{view} {update} {result} {delete}', 'buttons' => ['result' => function ($url, $model, $key) { if ($model->status == KefuSelfservice::STATUS_YICHULI) { return ""; } return Html::a('<span class="glyphicon glyphicon-check"></span>', ['/kefu-selfservice/result', 'id' => $model->id], ['title' => Yii::t('common', 'check'), 'id' => 'check' . $model->id]); }]]]]); ?> </div>
public function actionBugFanKui() { $model = new KefuSelfservice(); $cat = KefuSelfserviceCat::findOne(['slug' => 'bug-fan-kui']); $model->setAdditional(); if ($model->load(\Yii::$app->request->post()) && $model->save()) { \Yii::$app->session->setFlash('success', '您的建议已成功提交,谢谢您在百忙之中抽出时间给我们建议,我们会尽快处理!'); return $this->redirect(['selfservice-result']); } else { return $this->render('bug-fan-kui', ['model' => $model, 'cat' => $cat]); } }
?> "><h2 class="heading-md">账号修复</h2></a> <p>通过提交申诉表单修复自己的账号</p> </div> </div> <div class="col-md-4 col-sm-12"> <div class="service-block service-block-blue service-or"> <div class="service-bg"></div> <i class="icon-custom icon-color-light rounded-x icon-line fa fa-circle-thin"></i> <h2 class="heading-md">自助服务</h2> <p> <?php foreach (\common\models\KefuSelfserviceCat::find()->all() as $selfservices) { ?> <a href="<?php echo Url::to(['/kefu/' . $selfservices->slug]); ?> "><?php echo $selfservices->title; ?> </a> | <?php } ?> <a href="<?php echo Url::to(['/kefu/selfservice-result']); ?> ">结果</a>
/** * @return \yii\db\ActiveQuery */ public function getKefuSelfserviceCats() { return $this->hasMany(KefuSelfserviceCat::className(), ['parent_id' => 'id']); }
</div> </div> <div class="row"> <div class="col-md-12"> <div class="tag-box tag-box-v3"> <div class="headline"><h3><?php echo $this->title; ?> </h3></div> <?php $attachmentsImags = ''; foreach ($model->attachments as $ss) { $attachmentsImags .= Html::img(Yii::$app->glide->createSignedUrl(['glide/index', 'path' => $ss['path'], 'w' => 200], true), ['class' => 'img-responsive']); } ?> <?php echo DetailView::widget(['model' => $model, 'attributes' => [['attribute' => 'category_id', 'value' => \common\models\KefuSelfserviceCat::findOne($model->category_id)['title']], 'sn', 'game_role', ['attribute' => 'game_server', 'value' => \common\models\GameServer::findOne($model->game_server)['server_name']], ['attribute' => 'attachments', 'format' => 'html', 'value' => $attachmentsImags], 'content:html', 'created_at:datetime', ['attribute' => 'status', 'value' => ArrayHelper::getValue(KefuSelfservice::getStatus(), $model->status)], ['attribute' => 'result', 'format' => 'html', 'headerOptions' => ['width' => '500px']]]]); ?> </div> </div> </div> </div> <?php $js = <<<JS \$('.jie-guo').addClass('active'); JS; $this->registerJs($js);
/** * Finds the KefuSelfserviceCat model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return KefuSelfserviceCat the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = KefuSelfserviceCat::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
<div class="row"> <div class="col-md-12"> <div class="tag-box tag-box-v3"> <div class="headline"><h3><?php echo $this->title; ?> </h3></div> <?php if (!Yii::$app->user->isGuest) { ?> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'columns' => [['class' => 'yii\\grid\\ActionColumn', 'header' => '操作', 'template' => '{view}', 'buttons' => ['view' => function ($url, $model, $key) { return Html::a('查看', $url); }]], 'sn', ['attribute' => 'category_id', 'value' => function ($dataProvider) { $cat = $dataProvider->category_id; return \common\models\KefuSelfserviceCat::findOne(['id' => $cat])['title']; }], 'created_at:datetime', ['class' => \common\grid\EnumColumn::className(), 'attribute' => 'status', 'enum' => KefuSelfservice::getStatus()]], 'tableOptions' => ['class' => 'table table-bordered table-condensed table-hover table-striped', 'id' => 'index scroll'], 'layout' => "{items}\n{summary}\n{pager}"]); ?> <?php } else { ?> <?php echo Html::tag('h5', '没有记录!'); ?> <?php } ?> </div> </div> </div> </div>