Skip to main content
You can add extra properties to your data objects when they are transformed into a resource:
Output:

Using Closures

When using a closure, you have access to the underlying data object:
Output:

The with Method

Add extra properties by overwriting the with method within your data object:
Now each transformed data object contains an endpoints key:

Use Cases

Appending properties is useful for:

API Endpoints

Add related API endpoints for the resource

Computed Values

Include calculated or derived properties

Metadata

Attach metadata like timestamps or versions

Permissions

Include user-specific permission flags
The with method is called every time the data object is transformed, making it perfect for dynamic properties that depend on the current state.