Add notification filters

This commit is contained in:
2026-04-24 20:02:22 +00:00
parent 5f74ddd964
commit c54df44ebe
24 changed files with 1288 additions and 7 deletions
+64
View File
@@ -0,0 +1,64 @@
<?php
namespace App\Enums;
enum NotificationFilterAttribute: string
{
case ProjectId = 'project.id';
case ProjectKey = 'project.key';
case ProjectName = 'project.name';
case TicketId = 'ticket.id';
case TicketKey = 'ticket.key';
case TicketTitle = 'ticket.title';
case TicketUrl = 'ticket.url';
case ActorId = 'actor.id';
case ActorName = 'actor.name';
case StatusFromId = 'status.from.id';
case StatusFromLabel = 'status.from.label';
case StatusToId = 'status.to.id';
case StatusToLabel = 'status.to.label';
public function label(): string
{
return match ($this) {
self::ProjectId => 'Project ID',
self::ProjectKey => 'Project key',
self::ProjectName => 'Project name',
self::TicketId => 'Ticket ID',
self::TicketKey => 'Ticket key',
self::TicketTitle => 'Ticket title',
self::TicketUrl => 'Ticket URL',
self::ActorId => 'Actor ID',
self::ActorName => 'Actor name',
self::StatusFromId => 'From status ID',
self::StatusFromLabel => 'From status label',
self::StatusToId => 'To status ID',
self::StatusToLabel => 'To status label',
};
}
/**
* @return array<int, array{label: string, value: string}>
*/
public static function options(): array
{
return array_map(
static fn (self $attribute): array => [
'label' => $attribute->label(),
'value' => $attribute->value,
],
self::cases(),
);
}
/**
* @return array<int, string>
*/
public static function values(): array
{
return array_map(
static fn (self $attribute): string => $attribute->value,
self::cases(),
);
}
}
+48
View File
@@ -0,0 +1,48 @@
<?php
namespace App\Enums;
enum NotificationFilterOperator: string
{
case Equals = 'equals';
case NotEquals = 'not_equals';
case Exists = 'exists';
case NotExists = 'not_exists';
case In = 'in';
public function label(): string
{
return match ($this) {
self::Equals => 'Equals',
self::NotEquals => 'Not equals',
self::Exists => 'Exists',
self::NotExists => 'Not exists',
self::In => 'In list',
};
}
/**
* @return array<int, array{label: string, value: string}>
*/
public static function options(): array
{
return array_map(
static fn (self $operator): array => [
'label' => $operator->label(),
'value' => $operator->value,
],
self::cases(),
);
}
/**
* @return array<int, string>
*/
public static function values(): array
{
return array_map(
static fn (self $operator): string => $operator->value,
self::cases(),
);
}
}