fixe duploads and attachments now with colors tab and enhancements

This commit is contained in:
Mark Gregory
2026-06-16 19:01:26 +01:00
parent c19497efc2
commit f8ae45d810
8 changed files with 289 additions and 108 deletions
+25 -22
View File
@@ -209,37 +209,40 @@ final class TicketEdit extends Component
}
/**
* Return assignable users. Falls back to all tenant users when helpdesk flags/roles are absent.
* 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
{
return User::query()
->select(['id', 'name', 'email', 'company_id'])
->when($this->company_id !== null && Schema::hasColumn('users', 'company_id'), function ($query): void {
$query->where(function ($query): void {
$columns = ['id', 'name', 'email'];
if (Schema::hasColumn('users', 'company_id')) {
$columns[] = 'company_id';
}
$query = User::query()->select($columns)->orderBy('name');
if ($this->company_id !== null && Schema::hasColumn('users', 'company_id')) {
$tenantUsers = (clone $query)
->where(function ($query): void {
$query->where('company_id', $this->company_id)
->orWhereNull('company_id');
});
})
->when(Schema::hasColumn('users', 'helpdesk_agent') || Schema::hasColumn('users', 'helpdesk_admin'), function ($query): void {
$query->where(function ($query): void {
if (Schema::hasColumn('users', 'helpdesk_agent')) {
$query->orWhere('helpdesk_agent', true);
}
})
->when($this->agent_id !== null, function ($query): void {
$query->orWhereKey($this->agent_id);
})
->get();
if (Schema::hasColumn('users', 'helpdesk_admin')) {
$query->orWhere('helpdesk_admin', true);
}
if ($tenantUsers->isNotEmpty()) {
return $tenantUsers;
}
}
if ($this->agent_id !== null) {
$query->orWhereKey($this->agent_id);
}
});
})
->orderBy('name')
->get();
return $query->get();
}
private function freshTicket(Ticket $ticket): Ticket