/** * validate official qq * @return bool */ public function validateQq() { $qq = KefuQq::findOne(['qq' => $this->qq]); if ($qq != null) { return true; } return false; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = KefuQq::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'user_id' => $this->user_id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'status' => $this->status]); $query->andFilterWhere(['like', 'qq', $this->qq])->andFilterWhere(['like', 'user_name', $this->user_name]); return $dataProvider; }
<?php use yii\helpers\Html; use yii\widgets\DetailView; use yii\helpers\ArrayHelper; use common\models\KefuQq; /* @var $this yii\web\View */ /* @var $model common\models\KefuQq */ $this->title = $model->user_name; $this->params['breadcrumbs'][] = ['label' => Yii::t('common', 'Kefu QQ'), 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; ?> <div class="kefu-qq-view"> <p> <?php echo Html::a(Yii::t('common', 'Update'), ['update', 'id' => $model->id], ['class' => 'btn btn-primary']); ?> <?php echo Html::a(Yii::t('common', 'Delete'), ['delete', 'id' => $model->id], ['class' => 'btn btn-danger', 'data' => ['confirm' => Yii::t('common', 'Are you sure you want to delete this item?'), 'method' => 'post']]); ?> </p> <?php echo DetailView::widget(['model' => $model, 'attributes' => ['qq', 'user_id', 'user_name', 'created_at:datetime', 'updated_at:datetime', ['attribute' => 'status', 'value' => ArrayHelper::getValue(KefuQq::getStatus(), $model->status)]]]); ?> </div>
<?php use yii\helpers\Html; use yii\grid\GridView; use common\models\KefuQq; /* @var $this yii\web\View */ /* @var $searchModel backend\models\search\KefuQqSearch */ /* @var $dataProvider yii\data\ActiveDataProvider */ $this->title = Yii::t('common', 'Kefu QQ'); $this->params['breadcrumbs'][] = $this->title; ?> <div class="kefu-qq-index"> <?php // echo $this->render('_search', ['model' => $searchModel]); ?> <p> <?php echo Html::a(Yii::t('backend', 'Create {modelClass}', ['modelClass' => Yii::t('common', 'Kefu QQ')]), ['create'], ['class' => 'btn btn-success']); ?> </p> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'qq', 'user_name', 'created_at:datetime', ['class' => \common\grid\EnumColumn::className(), 'attribute' => 'status', 'enum' => KefuQq::getStatus()], ['class' => 'yii\\grid\\ActionColumn']]]); ?> </div>
/** * Finds the KefuQq model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return KefuQq the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = KefuQq::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }