breaking changes
This commit is contained in:
@@ -23,8 +23,8 @@ use Modules\Helpdesk\Models\Comment;
|
||||
use Modules\Helpdesk\Models\Priority;
|
||||
use Modules\Helpdesk\Models\Status;
|
||||
use Modules\Helpdesk\Models\Ticket;
|
||||
use Modules\Helpdesk\Services\CannedResponseRenderer;
|
||||
use Modules\Helpdesk\Services\AttachmentService;
|
||||
use Modules\Helpdesk\Services\CannedResponseRenderer;
|
||||
use Modules\Helpdesk\Services\ChecklistService;
|
||||
use Modules\Helpdesk\Services\SlaService;
|
||||
use Modules\Helpdesk\Services\TicketService;
|
||||
@@ -143,9 +143,6 @@ final class TicketShow extends Component
|
||||
$this->ticket = $this->freshTicket($this->ticket);
|
||||
}
|
||||
|
||||
/**
|
||||
* Persist the selected ticket status using a direct table update so Livewire UI wrappers cannot silently fail.
|
||||
*/
|
||||
public function updateStatus(WorkflowNotificationService $workflow, SlaService $sla): void
|
||||
{
|
||||
$this->authorize('update', $this->ticket);
|
||||
@@ -186,9 +183,6 @@ final class TicketShow extends Component
|
||||
$this->dispatch('helpdesk-status-updated', statusId: $this->status_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Persist the selected ticket priority using a direct table update.
|
||||
*/
|
||||
public function updatePriority(WorkflowNotificationService $workflow): void
|
||||
{
|
||||
$this->authorize('update', $this->ticket);
|
||||
@@ -222,9 +216,6 @@ final class TicketShow extends Component
|
||||
$this->dispatch('helpdesk-priority-updated', priorityId: $this->priority_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Persist the selected ticket assignee.
|
||||
*/
|
||||
public function updateAgent(WorkflowNotificationService $workflow): void
|
||||
{
|
||||
$this->authorize('update', $this->ticket);
|
||||
@@ -263,12 +254,6 @@ final class TicketShow extends Component
|
||||
$this->dispatch('helpdesk-agent-updated', agentId: $this->agent_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Persist one or more supporting files directly against an existing ticket.
|
||||
*
|
||||
* This is intentionally separate from comment attachments so users can add
|
||||
* evidence to an already-created ticket without posting another response.
|
||||
*/
|
||||
public function saveSupportingFiles(AttachmentService $attachments): void
|
||||
{
|
||||
$this->authorize('comment', $this->ticket);
|
||||
@@ -303,9 +288,6 @@ final class TicketShow extends Component
|
||||
])->layout('layouts.app');
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert Livewire select values into a nullable integer.
|
||||
*/
|
||||
private function normaliseNullableInt(mixed $value): ?int
|
||||
{
|
||||
if ($value === null || $value === '' || $value === '0' || $value === 0) {
|
||||
@@ -337,6 +319,9 @@ final class TicketShow extends Component
|
||||
|
||||
$comments = Comment::query()
|
||||
->where('ticket_id', $ticket->id)
|
||||
->when(Schema::hasColumn('helpdesk_comments', 'deleted_at'), static function ($query): void {
|
||||
$query->whereNull('deleted_at');
|
||||
})
|
||||
->when(Schema::hasColumn('helpdesk_comments', 'tombstoned_at'), static function ($query): void {
|
||||
$query->whereNull('tombstoned_at');
|
||||
})
|
||||
@@ -347,14 +332,26 @@ final class TicketShow extends Component
|
||||
->oldest()
|
||||
->get();
|
||||
|
||||
$ticket->setAttribute('public_replies_count', $comments->where('is_internal', false)->count());
|
||||
$ticket->setAttribute('time_spent_minutes', $this->sumCommentMinutes($comments));
|
||||
$ticket->setRelation('comments', $this->buildCommentTree($comments->groupBy('parent_id')));
|
||||
|
||||
return $ticket;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load owner and agent users with one query and attach aliases used by the view/workflow.
|
||||
*/
|
||||
private function sumCommentMinutes(Collection $comments): int
|
||||
{
|
||||
if (Schema::hasColumn('helpdesk_comments', 'time_spent_minutes')) {
|
||||
return (int) $comments->sum('time_spent_minutes');
|
||||
}
|
||||
|
||||
if (Schema::hasColumn('helpdesk_comments', 'minutes_logged')) {
|
||||
return (int) $comments->sum('minutes_logged');
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private function hydrateTicketUsers(Ticket $ticket): void
|
||||
{
|
||||
$userIds = collect([$ticket->user_id, $ticket->agent_id])
|
||||
@@ -385,14 +382,6 @@ final class TicketShow extends Component
|
||||
$ticket->setRelation('agent', $agent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return assignable users for this ticket.
|
||||
*
|
||||
* The dropdown must never be blank just because optional helpdesk_agent/helpdesk_admin
|
||||
* flags are missing or false. Prefer tenant/company users, then fall back to all users.
|
||||
*
|
||||
* @return EloquentCollection<int, User>
|
||||
*/
|
||||
private function agentOptions(): EloquentCollection
|
||||
{
|
||||
$columns = ['id', 'name', 'email'];
|
||||
@@ -422,9 +411,6 @@ final class TicketShow extends Component
|
||||
return $query->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* MPBA/core-company users can see internal notes. Other tenants only see public comments.
|
||||
*/
|
||||
private function canSeeInternalNotes(): bool
|
||||
{
|
||||
$company = Auth::user()?->company;
|
||||
|
||||
Reference in New Issue
Block a user