fixe duploads and attachments now with colors tab and enhancements
This commit is contained in:
@@ -41,11 +41,11 @@ final class TicketShow extends Component
|
||||
/** @var array<int, TemporaryUploadedFile> */
|
||||
public array $attachments = [];
|
||||
|
||||
public int|string|null $status_id = null;
|
||||
public ?int $status_id = null;
|
||||
|
||||
public int|string|null $priority_id = null;
|
||||
public ?int $priority_id = null;
|
||||
|
||||
public int|string|null $agent_id = null;
|
||||
public ?int $agent_id = null;
|
||||
|
||||
public ?int $reply_parent_id = null;
|
||||
|
||||
@@ -225,7 +225,10 @@ final class TicketShow extends Component
|
||||
|
||||
$agentId = $this->normaliseNullableInt($this->agent_id);
|
||||
|
||||
$this->validateAssignableAgent($agentId);
|
||||
validator(
|
||||
['agent_id' => $agentId],
|
||||
['agent_id' => ['nullable', 'integer', Rule::exists('users', 'id')]],
|
||||
)->validate();
|
||||
|
||||
abort_unless(Schema::hasColumn('helpdesk_tickets', 'agent_id'), 500, 'The helpdesk_tickets.agent_id column is missing.');
|
||||
|
||||
@@ -279,8 +282,8 @@ final class TicketShow extends Component
|
||||
private function freshTicket(Ticket $ticket): Ticket
|
||||
{
|
||||
$ticket = $ticket->fresh([
|
||||
'owner',
|
||||
'agent',
|
||||
'owner.company',
|
||||
'agent.company',
|
||||
'status',
|
||||
'priority',
|
||||
'category',
|
||||
@@ -307,39 +310,6 @@ final class TicketShow extends Component
|
||||
return $ticket;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that the selected agent exists and belongs to this ticket's company context.
|
||||
*/
|
||||
private function validateAssignableAgent(?int $agentId): void
|
||||
{
|
||||
if ($agentId === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
$rule = Rule::exists('users', 'id');
|
||||
|
||||
if ($this->ticket->company_id !== null && Schema::hasColumn('users', 'company_id')) {
|
||||
$ticketCompanyId = (int) $this->ticket->company_id;
|
||||
$currentAgentId = $this->ticket->agent_id === null ? null : (int) $this->ticket->agent_id;
|
||||
|
||||
$rule->where(function ($query) use ($ticketCompanyId, $currentAgentId): void {
|
||||
$query->where(function ($tenantQuery) use ($ticketCompanyId): void {
|
||||
$tenantQuery->where('company_id', $ticketCompanyId)
|
||||
->orWhereNull('company_id');
|
||||
});
|
||||
|
||||
if ($currentAgentId !== null) {
|
||||
$query->orWhere('id', $currentAgentId);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
validator(
|
||||
['agent_id' => $agentId],
|
||||
['agent_id' => ['nullable', 'integer', $rule]],
|
||||
)->validate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return assignable users for this ticket.
|
||||
*
|
||||
@@ -365,7 +335,7 @@ final class TicketShow extends Component
|
||||
->orWhereNull('company_id');
|
||||
})
|
||||
->when($this->agent_id !== null, function ($query): void {
|
||||
$query->orWhereKey($this->agent_id);
|
||||
$query->orWhere('id', $this->agent_id);
|
||||
})
|
||||
->get();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user