> ## Documentation Index
> Fetch the complete documentation index at: https://docs.vectorify.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Configuration

> Enter the tables and columns you want to be accessible by AI

The `config/vectorify.php` file is the central mechanism for defining how Laravel models are processed and upserted to Vectorify. Through a declarative configuration file, it handles collection (table) definitions, column mappings, metadata extraction, and tenancy configuration.

**Global Settings**

The configuration file contains several global settings that affect the entire package behaviour:

| Setting | Purpose |
| - | - |
| `api_key` | Authentication token for Vectorify |
| `tenancy` | Tenancy mode: `single` , `multi:column`, `multi:domain` |
| `collections` | Array of collection definitions |

**Collections**

As described in the [concepts](concepts) page, collections define how Laravel models are synchronized with Vectorify and can use three different syntax patterns. Each collection specifies the data source, field mappings, transformations, and metadata definitions.

## Simple Model Reference

The simplest collection configuration references a model class:

```php theme={null}
'collections' => [
    \App\Models\Invoice::class,
]
```

This approach uses the model's `$fillable` or a custom `$vectorify` property as the column list.

## Resource Class Integration

The `resource` configuration allows using Laravel [API Resources](https://laravel.com/docs/eloquent-resources) for data transformation:

```php theme={null}
'collections' => [
	'invoices' => [
		'query' => fn () => \App\Models\Invoice::query()->with('customer'),
		'resource' => \App\Http\Resources\InvoiceResource::class,
		'metadata' => [
			'customer_name' => [
				'type' => 'string',
			],
			'status' => [
				'type' => 'enum',
				'options' => ['draft', 'sent', 'paid'],
			],
			'due_date' => [
				'type' => 'datetime',
			],
		],
	],
],
```

`query` is a callable which returns `Illuminate\Database\Eloquent\Builder`.

## Named Model Columns

Complex collections use named keys with configuration arrays:

```php theme={null}
'collections' => [
	'invoices' => [
		'query' => fn () => \App\Models\Invoice::query()->with('customer'),
		'columns' => [
			'customer' => [
				'relationship' => true,
				'columns' => [
					'name' => [
						'alias' => 'customer_name',
						'metadata' => true,
						'type' => 'string',
					],
				],
			],
			'status' => [
				'metadata' => true,
				'type' => 'enum',
				'options' => ['draft', 'sent', 'paid'],
			],
			'amount',
			'currency_code' => [
				'alias' => 'currency',
			],
			'due_at' => [
				'alias' => 'due_date'
				'format' => 'Y-m-d',
				'metadata' => true,
				'type' => 'datetime',
			],
		],
	],
],
```

`query` is a callable which returns `Illuminate\Database\Eloquent\Builder`.

### Column Configuration

Complex columns use arrays to specify transformation and metadata options:

| Option | Purpose | Example |
| :- | :- | :- |
| `alias` | Rename field in output | `'alias' => 'customer_name'` |
| `data` | Include in data payload | `'data' => false` |
| `type` | Data type for formatting | `'type' => 'datetime'` |
| `format` | Date/time formatting | `'format' => 'Y-m-d'` |
| `metadata` | Include in metadata | `'metadata' => true` |
| `tenant` | Use for multi-tenancy | `'tenant' => true` |
| `relationship` | Define a relationship | `'relationship' => true` |

### Relationship Configuration

Relationships are configured using nested column structures:

```php theme={null}
'customer' => [
    'relationship' => true,
    'foreign_key' => 'customer_id', // optional
    'columns' => [
        'name' => [
            'alias' => 'customer_name',
            'metadata' => true,
        ],
    ],
],
```

## Metadata Configuration

[Metadata](concepts) defines additional filterable attributes that are stored separately from the row data.

### Column-Level Metadata

Metadata can be defined at the column level using the `metadata` flag:

```php theme={null}
'status' => [
    'metadata' => true,
    'type' => 'enum',
    'options' => ['draft', 'sent', 'paid'],
],
```

### Global Metadata

Alternatively, metadata can be defined globally, especially when using resource class:

```php theme={null}
'metadata' => [
    'customer_name' => [
		'type' => 'string',
	],
    'status' => [
        'type' => 'enum',
        'options' => ['draft', 'sent', 'paid'],
    ],
    'due_date' => [
		'type' => 'datetime',
	],
],
```

### Metadata Types

Supported metadata types include:

| Type | Purpose | Additional Config |
| :- | :- | :- |
| `string` | Text and numeric values | None |
| `datetime` | Date/time values | `format` option |
| `enum` | Enumerated values | `options` array |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.