Files
KanbanGit/app/Actions/Notifications/BuildTicketStatusChangedPayload.php
T

43 lines
1.3 KiB
PHP

<?php
namespace App\Actions\Notifications;
use App\Enums\NotificationEventType;
use App\Models\Project;
use App\Models\Ticket;
use App\Models\TicketStatus;
use App\Models\User;
use Carbon\CarbonImmutable;
class BuildTicketStatusChangedPayload
{
public function handle(
Project $project,
Ticket $ticket,
?User $actor,
int $originStatusId,
string $originLabel,
TicketStatus $destinationStatus,
string $destinationLabel,
CarbonImmutable $occurredAt,
): TicketStatusChangedPayload {
return new TicketStatusChangedPayload(
eventType: NotificationEventType::TicketStatusChanged,
projectId: $project->id,
projectKey: $project->key,
projectName: $project->name,
ticketId: $ticket->id,
ticketKey: $ticket->ticket_key,
ticketTitle: $ticket->title,
ticketUrl: route('projects.tickets.show', [$project, $ticket]),
actorId: $actor?->id,
actorName: $actor?->name,
fromStatusId: $originStatusId,
fromStatusLabel: $originLabel,
toStatusId: $destinationStatus->id,
toStatusLabel: $destinationLabel,
occurredAt: $occurredAt,
);
}
}