Attachment
Class · Sharkord\Models\Attachment
Class Attachment
Represents a file or media asset stored on the Sharkord server.
Returned as nested objects in payloads such as server logos and user avatars. This is a read-only data model — attachments are managed through dedicated storage endpoints, not through this class.
Examples
Section titled “Examples”$sharkord->servers->getSettings()->then(function (\Sharkord\Models\ServerSettings $settings) { if ($settings->logo) { echo "Logo: {$settings->logo->originalName}\n"; echo "Type: {$settings->logo->mimeType}\n"; echo "Size: {$settings->logo->size} bytes\n"; }});Properties
Section titled “Properties”| Property | Type | Description |
|---|---|---|
$id (read-only) | int | Unique attachment ID. |
$name (read-only) | string | Stored filename on the server. |
$originalName (read-only) | string | The original filename as uploaded by the user. |
$md5 (read-only) | string | MD5 hash of the file contents. |
$userId (read-only) | int | ID of the user who uploaded the file. |
$size (read-only) | int | File size in bytes. |
$mimeType (read-only) | string | MIME type (e.g. ‘image/gif’). |
$extension (read-only) | string | File extension including the leading dot (e.g. ‘.gif’). |
$createdAt (read-only) | int | Upload timestamp in milliseconds. |
$updatedAt (read-only) | `int | null` |
Methods
Section titled “Methods”__construct()
Section titled “__construct()”Attachment constructor.
Parameters
| Parameter | Type | Description |
|---|---|---|
$rawData | array | Raw attachment data from the API. |
static fromArray()
Section titled “static fromArray()”Factory method to create an Attachment from a raw API data array.
Parameters
| Parameter | Type | Description |
|---|---|---|
$raw | array | The raw attachment payload. |
Returns self
toArray()
Section titled “toArray()”Returns the attachment data as a plain array.
Returns array<string,mixed>
__get()
Section titled “__get()”Magic getter for attachment properties.
Parameters
| Parameter | Type | Description |
|---|---|---|
$name | string | Property name. |
Returns mixed
__isset()
Section titled “__isset()”Magic isset check.
Parameters
| Parameter | Type | Description |
|---|---|---|
$name | string | Property name. |
Returns bool