Attributes Overview
All behaviour in Simple Data Objects is declared via PHP attributes on constructor parameters (or on the class itself for #[TransformKeys]).
| Attribute | Target | Purpose |
|---|---|---|
#[Cast] | Parameter | Apply a type cast during hydration and serialization |
#[Rules] | Parameter | Laravel validation rules |
#[Flatten] | Parameter | Inline nested DTO fields into the parent array |
#[Hidden] | Parameter | Exclude from toArray() / JSON output |
#[IgnoreIfNull] | Parameter | Omit from output when value is null |
#[MapPropertyName] | Parameter | Map a different input key to this property |
#[TransformKeys] | Class | Transform all input keys at the class level |
#[DataCollection] | Parameter | Declare a typed collection property |