Earlier we saw how default values can be set for a data object, sometimes you want to set a default value based on other properties. For example, you might want to set aDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/spatie/laravel-data/llms.txt
Use this file to discover all available pages before exploring further.
full_name property based on a first_name and last_name property. You can do this by using a computed property:
Requirements for Computed Properties
Again there are a few conditions for this approach:Use a sole property
You must always use a sole property, a property within the constructor definition won’t work
Cannot be set in payload
Computed properties cannot be defined in the payload, a
CannotSetComputedValue will be thrown if this is the case