Uuid
Installs UUID generation behavior for model create operations.
The trait supports database-native UUID expressions or UUIDv7 values generated by the configured PhalconKit security service. UUIDs can be stored as strings or packed binary values depending on the model options.
- Full name:
\PhalconKit\Mvc\Model\Traits\Uuid
Methods
initializeUuid
Initialize the UUID transform behavior for create validation.
public initializeUuid(array<string,mixed>|null $options = null): void
Options default to the model options manager under uuid. Supported keys are:
field: target attribute name, defaultuuidnative: when true, use databaseUUID()expressionsbinary: when true, store UUIDs as binary values
Parameters:
| Parameter | Type | Description |
|---|---|---|
$options | array | UUID behavior options. |
Throws:
When the security service cannot be resolved through the PhalconKit DI contract. - ServiceException
getBinaryUuid
Convert a canonical UUID string to its packed binary representation.
private getBinaryUuid(string $uuid): string
Parameters:
| Parameter | Type | Description |
|---|---|---|
$uuid | string | UUID string with or without hyphens. |
Return Value:
Binary bytes suitable for binary UUID columns.
setUuidBehavior
Register the UUID transform behavior under the standard behavior name.
public setUuidBehavior(\PhalconKit\Mvc\Model\Behavior\Transformable $uuidBehavior): void
Parameters:
| Parameter | Type | Description |
|---|---|---|
$uuidBehavior | \PhalconKit\Mvc\Model\Behavior\Transformable | Configured transformable behavior. |
Throws:
When the current models manager does not expose the PhalconKit behavior registry. - ServiceException
getUuidBehavior
Retrieve the registered UUID transform behavior.
public getUuidBehavior(): \PhalconKit\Mvc\Model\Behavior\Transformable
Return Value:
Transformable behavior responsible for UUID values.
Throws:
When the current models manager does not expose the PhalconKit behavior registry. - ServiceException