Repository navigation
v0.1.0
Typed, extensible custom fields for Eloquent models, with filtering and sorting.
Your product defines the fields at runtime, your users fill them in, and the package
stores every value in a typed column, validates it, and exposes it to a request as a
filter and as a sort. Headless: no controllers, no routes, no UI.
Getting started
composer require plin-code/laravel-custom-fields
php artisan vendor:publish --tag="laravel-custom-fields"
php artisan migrateSet key_type and morph_key_type before migrating. Both accept id, uuid or ulid
and default to id. See the README.
What is in it
- Twelve field types: text, textarea, email, url, phone, number, decimal, boolean,
date, datetime, select, multiselect. Each owns its storage column, validation rules,
serialization, default and the query operations it declares. - Your own types: implement FieldType, register it, done. No change to the core.
- Stable slugs and option keys: a name can be renamed and an option deactivated
without touching the values already stored. - Partial and complete validation: a PATCH validates only what it sends, while a
complete write validates the state the record ends up with, stored values included. - Filtering and sorting through spatie/laravel-query-builder: equals, in, contains,
greater_than, less_than, between, is_null, is_not_null, contains_any, contains_all.
A field only ever exposes the operations its type can serve. - Configurable keys, tables, models and connections, plus five events and factories.
- English and Italian validation messages.
Requirements
PHP 8.4 or newer, Laravel 12 or 13.
Tested on SQLite, MySQL 8.4 and PostgreSQL 17, on PHP 8.4 and 8.5, on Linux and Windows.
Full Changelog: https://github.com/plin-code/laravel-custom-fields/commits/v0.1.0