PhoenixKitCRM.Schemas.Contact (PhoenixKitCRM v0.2.4)

Copy Markdown View Source

A CRM contact (client / customer / prospect).

Cloned in spirit from PhoenixKitStaff.Schemas.Person, with one critical difference: the link to a PhoenixKit User (user_uuid) is optional — most contacts never log in. The link is set only when the "allow login" checkbox is ticked (see PhoenixKitCRM.Contacts), never cast from form params, so a crafted payload can't link an arbitrary user.

Summary

Functions

Public changeset for create/edit. user_uuid is NOT castable here.

Best human label for a contact.

Sets or clears the optional user_uuid login link (controlled, not from form params).

Types

t()

@type t() :: %PhoenixKitCRM.Schemas.Contact{
  __meta__: term(),
  company_memberships:
    [PhoenixKitCRM.Schemas.CompanyMembership.t()]
    | Ecto.Association.NotLoaded.t(),
  email: String.t() | nil,
  inserted_at: DateTime.t() | nil,
  interactions:
    [PhoenixKitCRM.Schemas.Interaction.t()] | Ecto.Association.NotLoaded.t(),
  metadata: map(),
  name: String.t() | nil,
  notes: String.t() | nil,
  phone: String.t() | nil,
  status: String.t() | nil,
  updated_at: DateTime.t() | nil,
  user: PhoenixKit.Users.Auth.User.t() | Ecto.Association.NotLoaded.t() | nil,
  user_uuid: UUIDv7.t() | nil,
  uuid: UUIDv7.t() | nil
}

Functions

changeset(contact, attrs)

@spec changeset(t() | Ecto.Changeset.t(t()), map()) :: Ecto.Changeset.t(t())

Public changeset for create/edit. user_uuid is NOT castable here.

display_name(contact)

@spec display_name(t()) :: String.t()

Best human label for a contact.

soft_delete_status()

@spec soft_delete_status() :: String.t()

statuses()

@spec statuses() :: [String.t()]

trashed?(contact)

@spec trashed?(t()) :: boolean()