Created
October 22, 2017 05:02
getClient
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function getClient($id = null) { | |
if (!$this->Terminal->exists($id)) { | |
throw new NotFoundException(__('Invalid terminal')); | |
} | |
$options = array('conditions' => array('Terminal.' . $this->Terminal->primaryKey => $id)); | |
$this->set('terminal', $this->Terminal->find('first', $options)); | |
APP::import('Model','Client'); | |
$this->Client = new Client; | |
$results = $this->apiClient($id); | |
foreach($results as $result){ | |
$data = array( | |
'id' => $result->id, | |
'name' => $result->description, | |
'terminal_id' => $id, | |
'mdnsName' => $result->mdnsName, | |
'dhcpHostname' => $result->dhcpHostname, | |
'mac' => $result->mac, | |
'ip' => $result->ip, | |
'vlan' => $result->vlan, | |
'sent' => $result->usage->sent, | |
'recv' => $result->usage->recv, | |
); | |
$this->Client->save($data); | |
} | |
return $this->redirect(array('controller' => 'clients','action' => 'index')); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment