/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = AccessDeviceInfo::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $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, 'deviceId' => $this->deviceId, 'ifIndex' => $this->ifIndex, 'vlanId' => $this->vlanId, 'status' => $this->status, 'update_time' => $this->update_time]); $query->andFilterWhere(['like', 'deviceIp', $this->deviceIp])->andFilterWhere(['like', 'ifDesc', $this->ifDesc])->andFilterWhere(['like', 'learnIp', $this->learnIp])->andFilterWhere(['like', 'learnMac', $this->learnMac]); return $dataProvider; }
private function unBind($id) { $model = AccessDeviceInfo::findOne($id); if (!$model) { return false; } $bindId = $model->bindId; $url = $this->getApiUrl('/res/access/ipMacBind'); $url .= '/' . $bindId; $client = (new RestfulClient('http_imc'))->request('DELETE', $url); if ($client->getHttpCode() == 204) { AccessDeviceInfo::updateAll(['status' => 0, "bindId" => 0], ["id" => $id]); } return $client->getHttpCode() == 204; }
/** * Finds the AccessDeviceInfo model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return AccessDeviceInfo the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = AccessDeviceInfo::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }