/** * Creates data provider instance with search query applied * * @param array $params * @param string $formName the form name to be used for loading the data into the model. * * @return ActiveDataProvider */ public function search($params, $formName = null) { $query = DpAdminMenuUrl::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params, $formName); 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(['url_id' => $this->url_id, 'enable_rule' => $this->enable_rule, 'status' => $this->status]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'alias', $this->alias])->andFilterWhere(['like', 'route', $this->route])->andFilterWhere(['like', 'method', $this->method])->andFilterWhere(['like', 'host', $this->host])->andFilterWhere(['like', 'note', $this->note]); return $dataProvider; }
/** * 更新状态 * * @return array */ public function actionUpdateStatus() { $ids = \Yii::$app->request->post('ids'); $status = intval(\Yii::$app->request->post('status')); if ($status != 0) { $status = 1; } foreach (StringHelper::explode($ids, ',', true, true) as $id) { $obj = DpAdminMenuUrl::find()->findByUrlId($id)->one(); if ($obj) { $obj->status = $status; $obj->save(); } } return $this->renderSuccess('状态更新成功'); }