/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params, $num, $page) { $query = UserBaseInfo::find()->limit($num, ($page - 1) * $num); $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pagesize' => $num]]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'card_type' => $this->card_type, 'gender' => $this->gender, 'city' => $this->city, 'last_login_time' => $this->last_login_time, 'create_time' => $this->create_time, 'update_time' => $this->update_time, 'status' => $this->status]); // ]) // ->andFilterWhere(['between', 'last_login_time', $this->start, $this->end]); $query->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'realname', $this->realname])->andFilterWhere(['like', 'password', $this->password])->andFilterWhere(['like', 'password_salt', $this->password_salt])->andFilterWhere(['like', 'mobile', $this->mobile])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'card_id', $this->card_id])->andFilterWhere(['like', 'avatar', $this->avatar])->andFilterWhere(['like', 'company', $this->company])->andFilterWhere(['like', 'position', $this->position])->andFilterWhere(['like', 'reg_ip', $this->reg_ip])->andFilterWhere(['like', 'reg_channel', $this->reg_channel])->andFilterWhere(['like', 'last_login_ip', $this->last_login_ip]); return $dataProvider; }
} else { if ($gender == 2) { return '女'; } else { return '未设置'; } } }, 'filter' => UserBaseInfo::getType('gender', ['1' => '男', '2' => '女', '0' => '未设置'])], 'reg_ip', 'reg_channel', ['attribute' => 'last_login_time', 'value' => function ($model, $row) { return date('Y-m-d H:i:s', $model->last_login_time); }, 'filter' => false], ['attribute' => 'last_login_ip', 'filter' => false, 'value' => function ($model) { return $model->last_login_ip; }], ['attribute' => 'create_time', 'value' => function ($model, $row) { return date('Y-m-d H:i:s', $model->create_time); }, 'filter' => false], ['attribute' => 'update_time', 'value' => function ($model, $row) { return date('Y-m-d H:i:s', $model->update_time); }, 'filter' => false], ['attribute' => 'status', 'filter' => UserBaseInfo::getType('status', ['1' => '正常', '2' => '临时禁用', '0' => '删除']), 'value' => function ($model, $row) { $status = $model->status; if ($status == 1) { return '正常'; } else { if ($status == 2) { return '临时禁用'; } else { return '删除'; } } }], ['header' => '操作', 'class' => 'yii\\grid\\ActionColumn', 'template' => '{view} {update} {delete}', 'headerOptions' => ['width' => '70'], 'buttons' => ['delete' => function ($url, $model, $key) { $options = ['title' => Yii::t('yii', 'Delete'), 'aria-label' => Yii::t('yii', 'Delete'), 'data-confirm' => Yii::t('yii', 'Are you sure you want to delete this item?'), 'data-method' => 'post', 'data-pjax' => '0']; $status = $model->status; if ($status == 0 || $status == 2) { return;
/** * Finds the UserBaseInfo model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return UserBaseInfo the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = UserBaseInfo::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }