/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params, $num)
 {
     $query = ServiceBaseInfo::find();
     $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, 'create_time' => $this->create_time, 'update_time' => $this->update_time, 'user_id' => $this->user_id, 'status' => $this->status]);
     $query->andFilterWhere(['like', 'service_name', $this->service_name])->andFilterWhere(['like', 'service_id', $this->service_id])->andFilterWhere(['like', 'service_key', $this->service_key])->andFilterWhere(['like', 'service_desc', $this->service_desc])->andFilterWhere(['like', 'service_logo', $this->service_logo])->andFilterWhere(['like', 'api_url', $this->api_url]);
     return $dataProvider;
 }
Пример #2
0
$id = $session[AdminBaseInfo::SESSION_KEY_ADMIN]['id'];
if ($dbManager->checkAccess($id, 'admin')) {
    echo Html::a(Yii::t('app', '创建服务'), ['create'], ['class' => 'btn btn-success']);
}
?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn', 'header' => '序号'], 'service_name', 'service_id', 'service_key', 'service_desc', 'api_url:url', ['attribute' => 'create_time', 'value' => function ($model, $row) {
    return date('Y-m-d H:i:s', ServiceBaseInfo::getServiceById($row)['create_time']);
}], ['attribute' => 'update_time', 'value' => function ($model, $row) {
    return date('Y-m-d H:i:s', ServiceBaseInfo::getServiceById($row)['update_time']);
}], 'user_id', ['attribute' => 'status', 'value' => function ($model, $row) {
    $status = ServiceBaseInfo::getServiceById($row)['status'];
    if ($status == 1) {
        return '正常';
    } else {
        return '禁用';
    }
}, 'filter' => ServiceBaseInfo::getType('status', ['1' => '正常', '0' => '禁用'])], ['class' => 'yii\\grid\\ActionColumn', 'header' => '操作', '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 == 2 || $status == 0) {
        return;
    }
    return Html::a('<span class="glyphicon glyphicon-trash"></span>', $url, $options);
}]]]]);
?>

</div>
Пример #3
0
 /**
  * Finds the ServiceBaseInfo model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return ServiceBaseInfo the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = ServiceBaseInfo::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }