- Added migration for ticket assignment and comments (`assigned_user_id` and `ticket_replies` table). - Implemented `TicketAssignedNotification` and `TicketCommentedNotification`. - Created `ReplyData`, `TicketListData`, and `PostReplyRequest` data classes. - Introduced `ResolveNotificationRouteController` for modular notification redirection. - Updated UI to support assigning users and posting comments on tickets. - User is navigated to comments page when clicked on the ticket, upon navigation ticket details modal is opened. - Extended tests to cover assignments, comments, status transitions, and notifications.
35 lines
958 B
PHP
35 lines
958 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Data\Ui\Ticket;
|
|
|
|
use App\Models\TicketReply;
|
|
use Spatie\LaravelData\Data;
|
|
|
|
final class ReplyData extends Data
|
|
{
|
|
public function __construct(
|
|
public int $id,
|
|
public int $userId,
|
|
public string $userName,
|
|
public string $userInitials,
|
|
public array $userRoles,
|
|
public string $message,
|
|
public string $createdAt,
|
|
) {}
|
|
|
|
public static function fromModel(TicketReply $reply): self
|
|
{
|
|
return new self(
|
|
id: $reply->id,
|
|
userId: $reply->user_id,
|
|
userName: $reply->user->name,
|
|
userInitials: method_exists($reply->user, 'initials') ? $reply->user->initials() : mb_strtoupper(mb_substr($reply->user->name, 0, 2)),
|
|
userRoles: $reply->user->roles->pluck('name')->toArray(),
|
|
message: $reply->message,
|
|
createdAt: $reply->created_at->diffForHumans(),
|
|
);
|
|
}
|
|
}
|