icingadb-web/library/Icingadb/Model/Comment.php
2019-11-05 01:06:28 +01:00

69 lines
1.5 KiB
PHP

<?php
namespace Icinga\Module\Eagle\Model;
use Icinga\Module\Eagle\Model\Behavior\BoolCast;
use Icinga\Module\Eagle\Model\Behavior\Timestamp;
use ipl\Orm\Behaviors;
use ipl\Orm\Model;
use ipl\Orm\Relations;
class Comment extends Model
{
public function getTableName()
{
return 'comment';
}
public function getKeyName()
{
return 'id';
}
public function getColumns()
{
return [
'environment_id',
'object_type',
'host_id',
'service_id',
'name_checksum',
'properties_checksum',
'name',
'author',
'text',
'entry_type',
'entry_time',
'is_persistent',
'is_sticky',
'expire_time',
'zone_id'
];
}
public function getSortRules()
{
return ['entry_time DESC'];
}
public function createBehaviors(Behaviors $behaviors)
{
$behaviors->add(new BoolCast([
'is_persistent',
'is_sticky'
]));
$behaviors->add(new Timestamp([
'entry_time',
'expire_time'
]));
}
public function createRelations(Relations $relations)
{
$relations->belongsTo('environment', Environment::class);
$relations->belongsTo('host', Host::class)->setJoinType('LEFT');
$relations->belongsTo('service', Service::class)->setJoinType('LEFT');
$relations->belongsTo('zone',Zone::class);
}
}