Class LaravelUi5\Core\Attributes\Setting

Declarative setting definition for Configurable classes.

Apply this attribute multiple times on a class (e.g., Action handler, Resource/Data provider, Report provider) to declare the settings it depends on.

When to Use Settings vs. Custom Database Models

The Settings API is designed for lightweight, flexible configuration values that can be expressed as simple key–value pairs (strings, numbers, booleans, arrays, dates). It works well when the configuration is UI-driven, ephemeral, or low-risk:

  • UI filters and personalization (e.g., a card showing weekly hours for selected employees).
    • Display preferences (e.g., default currency, theme, date range presets).
    • Feature toggles or thresholds that may change frequently.
    • Lists of IDs that serve as filters, as long as you accept weak references (IDs stored without DB-level foreign keys).

By contrast, a custom database model should be used when the configuration expresses a business relationship or critical domain rule:

  • Relationships that must be referentially intact (e.g., employees assigned to cost centers).
    • Audit-relevant or legally binding data (e.g., who is eligible for billing, regulatory roles).
    • Data that requires strong constraints, migrations, or reporting queries (joins, aggregates).
    • Long-lived associations where zombie IDs (deleted or reassigned objects) are unacceptable.

Rule of Thumb

If a value is ephemeral, UI-scoped, or best-effortSettings are pragmatic and safe. If a value is domain-critical, audited, or relational in nature → design a dedicated DB model.

Notes

Weak foreign keys in Settings (e.g., arrays of BusinessPartner IDs) are acceptable if you sanitize them at runtime (ignore IDs that no longer exist). Settings should always store JSON-safe primitives (string, int, float, bool, date in ISO-8601, arrays thereof). You trade off referential integrity for developer speed. This is intentional.

Example

     key: 'billing.settlement.validation.maxHours',
     type: ValueType::Integer,
     default: 8,
     scope: SettingScope::Tenant,
     visibilityRole: SettingVisibilityRole::TenantAdmin
 )]```
Methods
Properties