Laravel Custom Fields
An extensible package to attach dynamic, schemaless custom fields to any Eloquent model effortlessly, perfect for multi-tenant and highly customizable apps.
No fields yet. Add one above.
{}
From a model to a form in four calls
Every snippet below is the package's own README example. Pick a step to see the code.
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use HyderKamran\CustomFields\Traits\HasCustomFields;
class Post extends Model
{
use HasCustomFields;
}
20 field types out of the box
The package ships these types, from a single-line text input to nested repeaters. New ones are registered in config/custom-fields.php.
- textSingle line
- textareaMulti-line
- numberNumeric
- emailEmail address
- passwordMasked input
- selectChoose one
- checkboxChoose many
- radioOne of a set
- booleanSwitch
- dateCalendar date
- datetimeDate and time
- timeTime of day
- urlWeb address
- colorColour picker
- rangeSlider
- fileUpload
- imageImage upload
- repeaterNested rows
- jsonStructured data
- wysiwygRich text
An API for headless apps, a contract for your own types
REST endpoints
When enabled in the config, the package exposes endpoints to read and save a model's custom fields.
- GET
/api/custom-fields/App\Models\Post/1 - POST
/api/custom-fields/App\Models\Post/1
{
"fields": {
"seo_title": "New Title via API",
"seo_description": "Updated meta description"
}
}
Your own field types
Register a new type in config/custom-fields.php by mapping a type slug to a class that implements FieldRendererContract.
- type slugthe name you use in
'type' => ... - rendereryour class, implementing the contract
- @customFieldsrenders it with every other field
Up and running in one migration
Laravel Custom Fields is maintained in the open, versioned semantically, and used in our own client projects — so fixes land upstream rather than in a private fork.
composer require hyder-kamran/laravel-custom-fields
# Publish the config, migrations and seeders
php artisan vendor:publish --tag="custom-fields-config"
php artisan vendor:publish --tag="custom-fields-migrations"
php artisan vendor:publish --tag="custom-fields-seeders"
php artisan migrate
# Optional: default field groups
php artisan db:seed --class=CustomFieldSeeder
From the package README on GitHub
| Package | hyder-kamran/laravel-custom-fields |
|---|---|
| Licence | MIT |
| Language | PHP / Laravel |
| Requires | PHP ^8.1Laravel 8 to 12 |
| Maintained by | ApexlyTech, in the open on GitHub |
Give every model the fields it needs
An extensible package to attach dynamic, schemaless custom fields to any Eloquent model effortlessly, perfect for multi-tenant and highly customizable apps.