PHPackages                             hyder-kamran/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. [Database &amp; ORM](/categories/database)
4. /
5. hyder-kamran/laravel-custom-fields

ActiveLibrary[Database &amp; ORM](/categories/database)

hyder-kamran/laravel-custom-fields
==================================

A powerful, production-ready Laravel package for dynamic custom fields — attach any field type to any Eloquent model.

1.0.0(1mo ago)41MITPHPPHP ^8.1

Since Jun 3Pushed 1mo agoCompare

[ Source](https://github.com/haider-kamran/laravel-custom-fields)[ Packagist](https://packagist.org/packages/hyder-kamran/laravel-custom-fields)[ RSS](/packages/hyder-kamran-laravel-custom-fields/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (11)Versions (2)Used By (0)

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

[](#laravel-custom-fields)

A powerful, production-ready Laravel package that allows you to dynamically attach custom fields to any Eloquent model, inspired by Advanced Custom Fields (ACF) for WordPress.

Requirements
------------

[](#requirements)

- PHP ^8.1
- Laravel ^8.0 | ^9.0 | ^10.0 | ^11.0 | ^12.0

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

[](#installation)

You can install the package via composer:

```
composer require hyder-kamran/laravel-custom-fields
```

Publish the configuration file and migrations:

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

Run the database migrations:

```
php artisan migrate
```

(Optional) Seed the database with some default custom field groups:

```
php artisan db:seed --class=CustomFieldSeeder
```

Setup
-----

[](#setup)

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

```
namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use HyderKamran\CustomFields\Traits\HasCustomFields;

class Post extends Model
{
    use HasCustomFields;
}
```

Usage
-----

[](#usage)

### Supported Field Types

[](#supported-field-types)

The package ships with 20 production-ready field types out of the box: `text`, `textarea`, `number`, `email`, `password`, `select`, `checkbox`, `radio`, `boolean` (switch), `date`, `datetime`, `time`, `url`, `color`, `range` (slider), `file`, `image`, `repeater`, `json`, and `wysiwyg`.

### 1. Creating Field Groups and Fields

[](#1-creating-field-groups-and-fields)

You can create Field Groups and assign them to specific models.

```
use HyderKamran\CustomFields\Models\FieldGroup;
use HyderKamran\CustomFields\Models\CustomField;
use App\Models\Post;

// Create a Field Group
$group = FieldGroup::create([
    'name' => 'SEO Settings',
    'model_type' => Post::class,
    'is_active' => true,
]);

// Add fields to the group
CustomField::create([
    'group_id' => $group->id,
    'name' => 'seo_title',
    'label' => 'SEO Title',
    'type' => 'text',
    'required' => true,
]);

CustomField::create([
    'group_id' => $group->id,
    'name' => 'seo_faqs',
    'label' => 'FAQs',
    'type' => 'repeater',
    'options' => [
        'sub_fields' => [
            ['name' => 'question', 'label' => 'Question', 'type' => 'text'],
            ['name' => 'answer', 'label' => 'Answer', 'type' => 'text'],
        ]
    ]
]);
```

### 2. Setting and Getting Field Values

[](#2-setting-and-getting-field-values)

```
$post = Post::find(1);

// Set a simple text field
$post->setCustomField('seo_title', 'My Awesome Post SEO Title');

// Set a repeater field
$post->setCustomField('seo_faqs', [
    ['question' => 'What is this?', 'answer' => 'It is a package.'],
    ['question' => 'Is it free?', 'answer' => 'Yes, MIT license.']
]);

// Retrieve a specific field value
$seoTitle = $post->getCustomField('seo_title');

// Retrieve all custom fields as a Collection
$allFields = $post->getAllCustomFields();
```

### 3. Rendering Forms

[](#3-rendering-forms)

The package provides a built-in rendering engine to generate form HTML for the assigned fields using Bootstrap 5 UI conventions.

In your Blade templates:

```

    @csrf

    @customFields($post)

    Save Settings

```

### 4. API Endpoints

[](#4-api-endpoints)

The package exposes RESTful API endpoints out of the box if enabled in the config.

**GET: Retrieve custom fields for a model**

```
GET /api/custom-fields/App\Models\Post/1

```

**POST: Save custom fields for a model**

```
POST /api/custom-fields/App\Models\Post/1
Content-Type: application/json

{
    "fields": {
        "seo_title": "New Title via API",
        "seo_description": "Updated meta description"
    }
}

```

Architecture
------------

[](#architecture)

The package follows standard Laravel best practices with a clean, extensible architecture. You can register new custom Field Types in the `config/custom-fields.php` file by mapping a type slug to a class that implements `FieldRendererContract`.

License
-------

[](#license)

The MIT License (MIT).

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance90

Actively maintained with recent releases

Popularity5

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

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

Unknown

Total

1

Last Release

52d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3443560?v=4)[Syed Kamran Haider](/maintainers/kamranhaider)[@kamranhaider](https://github.com/kamranhaider)

---

Tags

laraveleloquentcustom fieldsacfdynamic-fields

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9762.4M133](/packages/roots-acorn)[psalm/plugin-laravel

Psalm plugin for Laravel

3345.3M347](/packages/psalm-plugin-laravel)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

7.1k8.4M98](/packages/mongodb-laravel-mongodb)[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k15.1M136](/packages/laravel-pulse)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

45444.2k1](/packages/pressbooks-pressbooks)

PHPackages © 2026

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