Dynamic Data Modeling

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.

Open SourceLaravelPackageDatabase
App\Models\Postuse HasCustomFields
Add a field
Rendered form0 fields

    No fields yet. Add one above.

    Stored values
    {}
    
    Illustrative builder with sample fields; the package renders its own Bootstrap 5 form
    How it works

    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.

    app/Models/Post.php
    namespace App\Models;
     
    use Illuminate\Database\Eloquent\Model;
    use HyderKamran\CustomFields\Traits\HasCustomFields;
     
    class Post extends Model
    {
        use HasCustomFields;
    }
    
    Field types

    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.

    Schemaless attributesEloquent integrationDynamic typing
    • 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
    Beyond Blade

    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
    POST body
    {
        "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.

    1. type slugthe name you use in 'type' => ...
    2. rendereryour class, implementing the contract
    3. @customFieldsrenders it with every other field
    Install

    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.

    Terminal
    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

    Packagehyder-kamran/laravel-custom-fields
    LicenceMIT
    LanguagePHP / Laravel
    RequiresPHP ^8.1Laravel 8 to 12
    Maintained byApexlyTech, in the open on GitHub
    View 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.