Add Tags() and Event_Tags() functions to Event

pull/3779/head
Isaac Connor 2023-10-20 14:02:25 -04:00
parent d303927ad0
commit c287b7f645
1 changed files with 21 additions and 0 deletions

View File

@ -3,10 +3,15 @@ namespace ZM;
require_once('Storage.php');
require_once('functions.php');
require_once('Object.php');
require_once('Event_Tag.php');
require_once('Tag.php');
class Event extends ZM_Object {
protected static $table = 'Events';
protected $Tags;
protected $Event_Tags;
protected $defaults = array(
'Id' => null,
'Name' => '',
@ -738,6 +743,22 @@ class Event extends ZM_Object {
return $frame;
}
public function Event_Tags() {
if (!isset($this->Event_Tags)) {
$this->Event_Tags = $this->Id() ? Event_Tag::find(['EventId'=>$this->Id()]) : [];
}
return $this->Event_Tags;
}
public function Tags() {
if (!isset($this->Tags)) {
$this->Tags = array_map(function($t){return $t->Tag();}, $this->Event_Tags());
} else {
Debug("Have Tags");
}
return $this->Tags;
}
} # end class
?>