public function actionRegister() { $this->_device->saveAttributes(array('ip' => Yii::app()->request->userHostAddress)); $ifaces = Iface::model()->with('ports')->findAll('LOWER(device_id)=?', array(strtolower($this->_device->id))); if (!empty($ifaces)) { $tmpIfaces = []; foreach ($ifaces as $iface) { $tmpIface = $iface->attributes; foreach ($iface->ports as $port) { $tmpIface['ports'][] = $port->attributes; } $tmpIfaces[] = $tmpIface; } } $this->_sendResponse(200, $tmpIfaces); }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = Iface::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }