Add MonitorId to Zone fields and add Monitor() method

This commit is contained in:
Isaac Connor 2020-09-17 20:56:21 -04:00
parent 42dc4e46b1
commit 1701089211
1 changed files with 11 additions and 2 deletions

View File

@ -8,8 +8,9 @@ class Zone extends ZM_Object {
protected static $table = 'Zones';
protected $defaults = array(
'Id' => null,
'Name' => '',
'Id' => null,
'MonitorId' => null,
'Name' => '',
'Type' => 'Active',
'Units' => 'Pixels',
'CheckMethod' => 'Blobs',
@ -36,6 +37,14 @@ class Zone extends ZM_Object {
public static function find_one( $parameters = array(), $options = array() ) {
return ZM_Object::_find_one(get_class(), $parameters, $options);
}
public function Monitor() {
if ( isset($this->{'MonitorId'}) ) {
$Monitor = Monitor::find_one(array('Id'=>$this->{'MonitorId'}));
if ( $Monitor )
return $Monitor;
}
return new Monitor();
}
} # end class Zone
?>