Skip to content

Configuration ​

Publish the config file to change the defaults:

bash
php artisan vendor:publish --tag=custom-fields-config

This writes config/custom-fields.php.

KeyDefaultWhat it does
tables.fieldscustom_fieldsName of the field definitions table. Set before you migrate.
tables.valuescustom_field_valuesName of the values table. Set before you migrate.
models.fieldCustomField::classField model. Your class must extend the package model.
models.valueCustomFieldValue::classValue model. Your class must extend the package model.
run_migrationstrueRun the package migration with php artisan migrate.
stricttrueThrow on unknown field keys. See Validation.
scope_resolvernullClass that returns the current tenant. See Multi-tenancy.
delete_values_with_modeltrueDelete a model's values when the model is deleted.
eventstrueDispatch the package events.
cache.enabledfalseCache field definitions across requests.
cache.storenullCache store name. null uses the default store.
cache.ttl3600Seconds to keep cached definitions.

Your own models ​

To add relations or methods to the package models, extend them and point the config at your classes:

php
namespace App\Models;

use KenPrz\CustomFields\Models\CustomField as BaseCustomField;

class CustomField extends BaseCustomField
{
    protected $connection = 'tenant';
}
php
// config/custom-fields.php
'models' => [
    'field' => App\Models\CustomField::class,
    'value' => App\Models\CustomFieldValue::class,
],

Released under the MIT License.