icingadb-web/library/Icingadb/Model/NotificationHistory.php

59 lines
1.3 KiB
PHP

<?php
namespace Icinga\Module\Icingadb\Model;
use Icinga\Module\Icingadb\Model\Behavior\Timestamp;
use ipl\Orm\Behaviors;
use ipl\Orm\Model;
use ipl\Orm\Relations;
class NotificationHistory extends Model
{
public function getTableName()
{
return 'notification_history';
}
public function getKeyName()
{
return 'id';
}
public function getColumns()
{
return [
'environment_id',
'endpoint_id',
'object_type',
'host_id',
'service_id',
'notification_id',
'type',
'send_time',
'state',
'previous_hard_state',
'author',
'text',
'users_notified'
];
}
public function getSortRules()
{
return ['send_time DESC'];
}
public function createBehaviors(Behaviors $behaviors)
{
$behaviors->add(new Timestamp([
'send_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');
}
}