/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = GameGift::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'game_id' => $this->game_id, 'game_server_id' => $this->game_server_id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'status' => $this->status]); $query->andFilterWhere(['like', 'lb_gid', $this->lb_gid])->andFilterWhere(['like', 'lb_name', $this->lb_name])->andFilterWhere(['like', 'lb_type', $this->lb_type])->andFilterWhere(['like', 'lb_method', $this->lb_method])->andFilterWhere(['like', 'lb_content', $this->lb_content])->andFilterWhere(['like', 'slug', $this->slug]); return $dataProvider; }
/** * Finds the GameGift model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return GameGift the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = GameGift::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
use yii\helpers\Html; use yii\helpers\ArrayHelper; use yii\grid\GridView; use common\models\GameGift; /* @var $this yii\web\View */ /* @var $searchModel backend\models\search\GameGiftSearch */ /* @var $dataProvider yii\data\ActiveDataProvider */ $this->title = Yii::t('common', 'Game Gift'); $this->params['breadcrumbs'][] = $this->title; ?> <div class="game-gift-index"> <?php // echo $this->render('_search', ['model' => $searchModel]); ?> <p> <?php echo Html::a(Yii::t('backend', 'Create {modelClass}', ['modelClass' => Yii::t('common', 'Game Gift')]), ['create'], ['class' => 'btn btn-success']); ?> </p> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'game_server_id', 'value' => function ($model) { return $model->gameServer->server_name; }, 'filter' => ArrayHelper::map(\common\models\GameServer::find()->all(), 'id', 'server_name')], 'lb_gid', 'lb_name', ['class' => \common\grid\EnumColumn::className(), 'attribute' => 'status', 'enum' => GameGift::getStatus()], ['class' => 'yii\\grid\\ActionColumn']], 'layout' => "{items}\n{summary}\n{pager}"]); ?> </div>
<?php use yii\helpers\Html; use yii\helpers\ArrayHelper; use yii\widgets\DetailView; use common\models\GameGift; /* @var $this yii\web\View */ /* @var $model common\models\GameGift */ $this->title = $model->lb_name; $this->params['breadcrumbs'][] = ['label' => Yii::t('common', 'Game Gift'), 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; ?> <div class="game-gift-view"> <p> <?php echo Html::a(Yii::t('backend', 'Update'), ['update', 'id' => $model->id], ['class' => 'btn btn-primary']); ?> <?php echo Html::a(Yii::t('backend', 'Delete'), ['delete', 'id' => $model->id], ['class' => 'btn btn-danger', 'data' => ['confirm' => Yii::t('backend', 'Are you sure you want to delete this item?'), 'method' => 'post']]); ?> </p> <?php echo DetailView::widget(['model' => $model, 'attributes' => ['game_server_id', 'lb_gid', 'lb_name', 'lb_type', 'lb_method:ntext', 'lb_content:ntext', 'slug', 'created_at:datetime', 'updated_at:datetime', ['attribute' => 'status', 'value' => ArrayHelper::getValue(GameGift::getStatus(), $model->status)]]]); ?> </div>
echo $form->field($model, 'lb_name')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'lb_type')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'lb_method')->textarea(['rows' => 6]); ?> <?php echo $form->field($model, 'lb_content')->textarea(['rows' => 6]); ?> <?php echo $form->field($model, 'status')->dropDownList(GameGift::getStatus()); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? Yii::t('backend', 'Create') : Yii::t('backend', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div> <?php ActiveForm::end(); ?> </div>