Attachment
Attachment stores uploaded file metadata for attachable records.
In practice, this is commonly used for message attachments and group covers.
This model is tightly coupled to storage config, URL generation, and file cleanup.
Core fields:
| Field | Purpose |
|---|---|
attachable_id |
Parent model id. |
attachable_type |
Parent model morph class. |
file_path |
Storage path on the configured disk. |
file_name |
Stored file name. |
original_name |
Original uploaded file name. |
mime_type |
Stored MIME type. |
url |
Computed URL accessor based on storage config. |
Important Relationships
attachable(): MorphTo
Returns the model this attachment belongs to, usually a Message or Group.
$attachment->attachable
Important Accessors
$attachment->url
Returns a public URL or a temporary private URL depending on the global Wirechat storage configuration.
$attachment->url
$attachment->size
Returns the file size in bytes when the file exists on disk.
$attachment->size
$attachment->formatted_size
Returns the file size in a human-readable format.
$attachment->formatted_size
$attachment->extension
Returns an extension-like value derived from the MIME type.
$attachment->extension
$attachment->clean_mime_type
Returns the MIME subtype, such as png, pdf, or zip.
$attachment->clean_mime_type
If you customize this model, preserve the filesystem cleanup behavior unless you are intentionally replacing it with your own storage lifecycle.