Search documentation of phoenix_kit

# PhoenixKit.Modules.CustomerService.TicketAttachment (phoenix_kit v1.7.87)

Copy Markdown View Source

Junction schema for ticket and comment attachments.

Links tickets or comments to uploaded files (images, documents, etc.) with ordering and optional captions. An attachment belongs to either a ticket directly OR a comment, but not both.

## Fields

- `ticket_uuid` - Reference to ticket (if attached to ticket directly)
- `comment_uuid` - Reference to comment (if attached to comment)
- `file_uuid` - Reference to the uploaded file (PhoenixKit.Storage.File)
- `position` - Display order (1, 2, 3, etc.)
- `caption` - Optional caption/alt text

Note: Either `ticket_uuid` OR `comment_uuid` must be set, but not both.

## Examples

    # Attachment on ticket itself
    %TicketAttachment{
      ticket_uuid: "018e3c4a-9f6b-7890-abcd-ef1234567890",
      comment_uuid: nil,
      file_uuid: "018e3c4a-1234-5678-abcd-ef1234567890",
      position: 1,
      caption: "Screenshot of the error"
    }

    # Attachment on a comment
    %TicketAttachment{
      ticket_uuid: nil,
      comment_uuid: "018e3c4a-5678-1234-abcd-ef1234567890",
      file_uuid: "018e3c4a-abcd-efgh-ijkl-mnopqrstuvwx",
      position: 1,
      caption: nil
    }

## Summary

### Types

t()

### Functions

changeset(attachment, attrs)

Changeset for creating or updating an attachment.

comment_attachment?(arg1)

Check if attachment is attached to a comment.

ticket_attachment?(arg1)

Check if attachment is attached to a ticket directly.

## Types

# t()

    @type t() :: %PhoenixKit.Modules.CustomerService.TicketAttachment{
      __meta__: term(),
      caption: String.t() | nil,
      comment:
        PhoenixKit.Modules.CustomerService.TicketComment.t()
        | Ecto.Association.NotLoaded.t()
        | nil,
      comment_uuid: UUIDv7.t() | nil,
      file: PhoenixKit.Modules.Storage.File.t() | Ecto.Association.NotLoaded.t(),
      file_uuid: UUIDv7.t(),
      inserted_at: DateTime.t() | nil,
      position: integer(),
      ticket:
        PhoenixKit.Modules.CustomerService.Ticket.t()
        | Ecto.Association.NotLoaded.t()
        | nil,
      ticket_uuid: UUIDv7.t() | nil,
      updated_at: DateTime.t() | nil,
      uuid: UUIDv7.t() | nil
    }

## Functions

# changeset(attachment, attrs)

Changeset for creating or updating an attachment.

## Required Fields

- `file_uuid` - Reference to file
- `position` - Display order (must be positive)
- Either `ticket_uuid` OR `comment_uuid` (but not both)

## Validation Rules

- Position must be greater than 0
- Must have exactly one of ticket_uuid or comment_uuid

# comment_attachment?(arg1)

Check if attachment is attached to a comment.

# ticket_attachment?(arg1)

Check if attachment is attached to a ticket directly.