Initial commit of MVC for Monitors

This commit is contained in:
Kyle Johnson 2013-05-01 18:41:59 -04:00
parent a5e2f29a4b
commit 055d8f8d0b
3 changed files with 45 additions and 0 deletions

View File

@ -0,0 +1,23 @@
<?php
class MonitorsController extends AppController {
public $helpers = array('Html', 'Form');
public function index() {
$this->set('monitors', $this->Monitor->find('all'));
}
public function view($id = null) {
if (!$id) {
throw new NotFoundException(__('Invalid monitor'));
}
$monitor = $this->Monitor->findById($id);
if (!$monitor) {
throw new NotFoundException(__('Invalid monitor'));
}
$this->set('monitor', $monitor);
}
}
?>

View File

@ -0,0 +1,5 @@
<?php
class Monitor extends AppModel {
public $useTable = 'Monitors';
}
?>

View File

@ -0,0 +1,17 @@
<h2>Monitors</h2>
<table>
<tr>
<th>Name</th>
<th>MonitorId</th>
</tr>
<?php foreach ($monitors as $monitor): ?>
<tr>
<td>
<?php echo $this->Html->link($monitor['Monitor']['Name'],
array('controller' => 'monitors', 'action' => 'view', $monitor['Monitor']['Id'])); ?>
<td><?php echo $monitor['Monitor']['Id']; ?></td>
</tr>
<?php endforeach; ?>
<?php unset($monitor); ?>
</table>