# Model Metadata

Model configuration files under `models/` may include a `metadata` array that gives front‑end helpers extra information about the table. This metadata is automatically returned by the API whenever it is defined.

## booleanFields

`booleanFields` lists columns that represent true/false values. DataLoader renders these fields with check icons and uses checkbox inputs when filtering or editing.

```php
'metadata' => [
    'booleanFields' => ['approved', 'billed_to_client']
]
```

## dateFields

`dateFields` tells the front-end which columns hold date values. DataLoader will
render these fields using HTML5 `<input type="date">` controls when filtering
or editing inline.

```php
'metadata' => [
    'dateFields' => ['posted_at']
]
```

## relations

`relations` describes foreign key fields. Each entry provides the related `table`, the `display_column` used for labels, the `value_column` for option values and an optional `filter` to limit rows. DataLoader loads these tables through `SyncManager` to build select boxes and search inputs.  
The array key may be an alias when the database column name differs. Include an `id_field` property pointing at the actual column name.

```php
'metadata' => [
    'relations' => [
        'reviewer' => [
            'id_field' => 'assigned_reviewer_id',
            'table' => 'users',
            'display_column' => 'full_name',
            'value_column'   => 'id',
            'filter' => ['groups.name' => 'reviewer']
        ]
    ]
]
```

## calculatedColumns

`calculatedColumns` defines JavaScript expressions evaluated for each record. The keys are new column names and the values are formulas using other fields in the row.

```php
'metadata' => [
    'calculatedColumns' => [
        'total' => 'hours * rate'
    ]
]
```

When DataLoader loads metadata it compiles these formulas so the calculated values appear alongside the regular fields.
