PHPackages                             skylence/laravel-custom-fields - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. skylence/laravel-custom-fields

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

skylence/laravel-custom-fields
==============================

Dynamic custom fields for Laravel Eloquent models with Filament integration

v1.2.0(2mo ago)03.9k↓50%[5 PRs](https://github.com/skylence-be/laravel-custom-fields/pulls)MITPHPPHP ^8.2CI passing

Since Oct 21Pushed 1mo agoCompare

[ Source](https://github.com/skylence-be/laravel-custom-fields)[ Packagist](https://packagist.org/packages/skylence/laravel-custom-fields)[ Docs](https://github.com/skylence/laravel-custom-fields)[ GitHub Sponsors](https://github.com/xve)[ RSS](/packages/skylence-laravel-custom-fields/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (32)Versions (16)Used By (0)

Laravel Custom Fields
=====================

[](#laravel-custom-fields)

[![Latest Version on Packagist](https://camo.githubusercontent.com/b21520610e10f2049687f76ac0a8fbf42a764b04bd5a18001635b02842fb73c8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7876652f6c61726176656c2d637573746f6d2d6669656c64732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/xve/laravel-custom-fields)[![Total Downloads](https://camo.githubusercontent.com/2a865fdc7c8f9bfd6315e4e8e189fce2b912430c9b7b3245c1b80c82b73b216c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7876652f6c61726176656c2d637573746f6d2d6669656c64732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/xve/laravel-custom-fields)

A powerful Laravel package that allows you to dynamically add custom fields to any Eloquent model without modifying your database schema or codebase. Built with Livewire 3 for a modern, reactive admin interface.

Features
--------

[](#features)

- ✅ **11 Field Types**: Text, Textarea, Select, Radio, Checkbox, Toggle, Checkbox List, DateTime, Rich Editor, Markdown, Color Picker
- ✅ **Column-Based Storage**: Custom fields are stored as actual database columns for optimal performance
- ✅ **Livewire 3 UI**: Modern, reactive admin interface for managing custom fields
- ✅ **Simple Integration**: Just add a trait to your models
- ✅ **Automatic Column Management**: Database columns are created/deleted automatically
- ✅ **Soft Deletes**: Safe deletion with optional permanent removal
- ✅ **Searchable &amp; Filterable**: Built-in search and filtering in the admin interface
- ✅ **Sortable Fields**: Control the display order of your custom fields
- ✅ **Validation Support**: Full Laravel validation rule support
- ✅ **Multi-Model Support**: Add custom fields to multiple models

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require xve/laravel-custom-fields
```

Run the migrations:

```
php artisan migrate
```

**That's it!** The package works out of the box with sensible defaults.

### Optional: Publish Configuration

[](#optional-publish-configuration)

You only need to publish the config if you want to customize routes, middleware, or other settings:

```
php artisan vendor:publish --tag="custom-fields-config"
```

### Optional: Publish Views

[](#optional-publish-views)

You only need to publish views if you want to customize the admin interface:

```
php artisan vendor:publish --tag="custom-fields-views"
```

Configuration
-------------

[](#configuration)

The package works with sensible defaults. If you've published the config file, it's located at `config/custom-fields.php`:

```
return [
    // Route configuration (default: /admin/fields with web & auth middleware)
    'route' => [
        'prefix' => 'admin/fields',
        'middleware' => ['web', 'auth'],
        'name_prefix' => 'custom-fields.',
    ],

    // Database table name (default: custom_fields)
    'table_name' => 'custom_fields',

    // Models that can have custom fields (optional - for UI dropdown)
    'customizable_types' => [
        // Example: App\Models\User::class => 'Users',
        // Example: App\Models\Post::class => 'Posts',
    ],

    // Pagination (default: 15)
    'per_page' => 15,

    // Enable soft deletes (default: true)
    'enable_soft_deletes' => true,

    // Enable default option selection (default: true)
    'enable_default_options' => true,
];
```

Usage
-----

[](#usage)

### Step 1: Add Trait to Your Model

[](#step-1-add-trait-to-your-model)

Add the `HasCustomFields` trait to any model you want to support custom fields:

```
use Illuminate\Database\Eloquent\Model;
use Skylence\LaravelCustomFields\Traits\HasCustomFields;

class Employee extends Model
{
    use HasCustomFields;

    protected $fillable = [
        'name',
        'email',
        // Custom field codes will be automatically merged
    ];
}
```

### Step 2: Create Custom Fields via Admin Interface

[](#step-2-create-custom-fields-via-admin-interface)

Navigate to `/admin/fields` in your browser to access the custom fields management interface.

**Create a new field:**

1. Click "Create New Field"
2. Fill in the details:

    - **Name**: Display label (e.g., "Employee Rating")
    - **Code**: Database column name (e.g., "employee\_rating")
    - **Type**: Select from 11 field types
    - **Model Type**: Select which model this field belongs to
    - **Options**: Add options for select/radio/checkbox list types
    - **Display Settings**: Toggle "Show in table columns"
3. Click "Create Field"

The package will automatically:

- Create a database column on the model's table
- Make the field available in your model
- Add appropriate casts and fillable attributes

### Step 3: Use Custom Fields in Your Code

[](#step-3-use-custom-fields-in-your-code)

Once created, custom fields work like regular model attributes:

```
// Create a new record with custom fields
$employee = Employee::create([
    'name' => 'John Doe',
    'email' => 'john@example.com',
    'employee_rating' => 'Excellent', // Custom field
    'department_code' => 'IT',         // Custom field
]);

// Update custom fields
$employee->employee_rating = 'Good';
$employee->save();

// Access custom field values
echo $employee->employee_rating; // 'Good'

// Use helper methods
$rating = $employee->getCustomField('employee_rating');
$employee->setCustomField('employee_rating', 'Excellent');

// Get all custom field values
$customValues = $employee->getCustomFieldValues();
```

### Step 4: Query with Custom Fields

[](#step-4-query-with-custom-fields)

Custom fields are stored as actual database columns, so you can use them in queries:

```
// Where clauses
$employees = Employee::where('employee_rating', 'Excellent')->get();

// Order by
$employees = Employee::orderBy('department_code')->get();

// Select specific fields
$employees = Employee::select('name', 'employee_rating')->get();
```

Field Types
-----------

[](#field-types)

The package supports 11 different field types:

- **Text Input**: Basic text with subtypes (email, numeric, integer, password, tel, url)
- **Textarea**: Multi-line text
- **Select Dropdown**: Single or multi-select with custom options
- **Radio Buttons**: Mutually exclusive options
- **Checkbox**: Single boolean checkbox
- **Toggle**: Toggle switch (boolean)
- **Checkbox List**: Multiple checkboxes (array)
- **Date &amp; Time**: DateTime picker
- **Rich Text Editor**: WYSIWYG editor
- **Markdown Editor**: Markdown with preview
- **Color Picker**: Color selection

Admin Interface Routes
----------------------

[](#admin-interface-routes)

The package provides three main routes:

- **Index**: `/admin/fields` - List all custom fields
- **Create**: `/admin/fields/create` - Create a new custom field
- **Edit**: `/admin/fields/{field}/edit` - Edit an existing custom field

All routes are protected by the middleware specified in the config file (default: `['web', 'auth']`).

Programmatic Field Creation
---------------------------

[](#programmatic-field-creation)

You can also create fields programmatically:

```
use Skylence\LaravelCustomFields\Models\Field;

Field::create([
    'name' => 'Employee Rating',
    'code' => 'employee_rating',
    'type' => 'select',
    'options' => ['Excellent', 'Good', 'Average', 'Poor'],
    'customizable_type' => App\Models\Employee::class,
    'use_in_table' => true,
    'sort' => 10,
]);
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Jonas Vanderhaegen](https://github.com/jonasvanderhaegen-xve)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

47

—

FairBetter than 94% of packages

Maintenance89

Actively maintained with recent releases

Popularity24

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 65.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~21 days

Recently: every ~13 days

Total

8

Last Release

60d ago

Major Versions

v0.1.0 → v1.0.02026-01-14

### Community

Maintainers

![](https://www.gravatar.com/avatar/8ad0eeb3e0f0183e243d7edf649313243750f8048918eb00c9c041c5dc379149?d=identicon)[skylence](/maintainers/skylence)

---

Top Contributors

[![jonasvanderhaegen-xve](https://avatars.githubusercontent.com/u/216873699?v=4)](https://github.com/jonasvanderhaegen-xve "jonasvanderhaegen-xve (21 commits)")[![jonasvanderhaegen](https://avatars.githubusercontent.com/u/7755555?v=4)](https://github.com/jonasvanderhaegen "jonasvanderhaegen (8 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (1 commits)")

---

Tags

laravelcustom fieldsfilamentlaravel-custom-fieldsskylence

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/skylence-laravel-custom-fields/health.svg)

```
[![Health](https://phpackages.com/badges/skylence-laravel-custom-fields/health.svg)](https://phpackages.com/packages/skylence-laravel-custom-fields)
```

###  Alternatives

[leandrocfe/filament-apex-charts

Apex Charts integration for Filament PHP.

4861.2M8](/packages/leandrocfe-filament-apex-charts)[spatie/laravel-livewire-wizard

Build wizards using Livewire

4061.0M4](/packages/spatie-laravel-livewire-wizard)[codewithdennis/filament-select-tree

The multi-level select field enables you to make single selections from a predefined list of options that are organized into multiple levels or depths.

320392.1k17](/packages/codewithdennis-filament-select-tree)[pboivin/filament-peek

Full-screen page preview modal for Filament

253319.6k12](/packages/pboivin-filament-peek)[dotswan/filament-map-picker

Easily pick and retrieve geo-coordinates using a map-based interface in your Filament applications.

124139.3k2](/packages/dotswan-filament-map-picker)[ralphjsmit/livewire-urls

Get the previous and current url in Livewire.

82270.3k4](/packages/ralphjsmit-livewire-urls)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
