'UID', 'url' => 'Url', 'name' => 'Name', 'website' => 'Website', 'visible' => 'Visible', 'last_updated' => 'LastUpdated', 'custom_name' => 'CustomName', 'custom_image' => 'CustomImage', 'custom_url' => 'CustomUrl', '_category' => 'CategoryID' ]; public static $RELATIONS = [ 'Entries' => [self::HAS_MANY, 'Entry', '_calendar'], 'Category' => [self::BELONGS_TO, 'Category', '_category'] ]; const CUSTOM_IMAGE_PATH = 'resources/images/calendars'; public function getCustomImageUrl() { if ($this->CustomImage) { if (!preg_match('#^//#', $this->CustomImage)) { return Prado::getApplication()->getAssetManager()->publishFilePath( implode( DIRECTORY_SEPARATOR, [ Prado::getApplication()->getBasePath(), self::CUSTOM_IMAGE_PATH, $this->CustomImage ] ), TRUE ); } return $this->CustomImage; } } public function getCustomImagePath(string $forFile = '', string $type = '') { $pathParts = [ Prado::getApplication()->getBasePath(), self::CUSTOM_IMAGE_PATH ]; if ($forFile) { $pathParts[] = $this->_getCustomImageHash($forFile, $type); } return implode(DIRECTORY_SEPARATOR, $pathParts); } private function _getCustomImageHash(string $file, string $type) { $hash = md5($file . md5_file($file) . filemtime($file)); if ($type) { $hash .= '.' . preg_replace('#^image/#', '', $type); } return $hash; } public function saveData(array $data) { $this->copyFrom($data); return $this->save(); } } ?>