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.'); } }