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:

SettingPurpose
api_keyAuthentication token for Vectorify
tenancyTenancy mode: single , multi:column, multi:domain
collectionsArray of collection definitions

Collections

As described in the 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:

'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 for data transformation:

'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:

'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:

OptionPurposeExample
aliasRename field in output'alias' => 'customer_name'
dataInclude in data payload'data' => false
typeData type for formatting'type' => 'datetime'
formatDate/time formatting'format' => 'Y-m-d'
metadataInclude in metadata'metadata' => true
tenantUse for multi-tenancy'tenant' => true
relationshipDefine a relationship'relationship' => true

Relationship Configuration

Relationships are configured using nested column structures:

'customer' => [
    'relationship' => true,
    'foreign_key' => 'customer_id', // optional
    'columns' => [
        'name' => [
            'alias' => 'customer_name',
            'metadata' => true,
        ],
    ],
],

Metadata Configuration

Metadata 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:

'status' => [
    'metadata' => true,
    'type' => 'enum',
    'options' => ['draft', 'sent', 'paid'],
],

Global Metadata

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

'metadata' => [
    'customer_name' => [
		'type' => 'string',
	],
    'status' => [
        'type' => 'enum',
        'options' => ['draft', 'sent', 'paid'],
    ],
    'due_date' => [
		'type' => 'datetime',
	],
],

Metadata Types

Supported metadata types include:

TypePurposeAdditional Config
stringText and numeric valuesNone
datetimeDate/time valuesformat option
enumEnumerated valuesoptions array