PHPackages                             aurorawebsoftware/flexyfield - 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. aurorawebsoftware/flexyfield

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

aurorawebsoftware/flexyfield
============================

Laravel Models are now Uber Flexy!

12.10.0(5mo ago)231.5k21MITPHPPHP ^8.2|^8.3|^8.4CI passing

Since Sep 7Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/AuroraWebSoftware/FlexyField)[ Packagist](https://packagist.org/packages/aurorawebsoftware/flexyfield)[ Docs](https://github.com/aurorawebsoftware/flexyfield)[ GitHub Sponsors](https://github.com/AuroraWebSoftware)[ RSS](/packages/aurorawebsoftware-flexyfield/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (12)Versions (25)Used By (1)

FlexyField
==========

[](#flexyfield)

### Because your models deserve superpowers 🦸

[](#because-your-models-deserve-superpowers-)

[![Build Status](https://github.com/aurorawebsoftware/flexyfield/actions/workflows/tests.yml/badge.svg)](https://github.com/aurorawebsoftware/flexyfield/actions)[![Latest Stable Version](https://camo.githubusercontent.com/ce64bd86ec7785db43ba5803d5c3937c6913ed458240287e1a53454340c2f7ca/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6175726f7261776562736f6674776172652f666c6578796669656c64)](https://packagist.org/packages/aurorawebsoftware/flexyfield)[![Total Downloads](https://camo.githubusercontent.com/2ddab9ecf75754049886baf11abd77bbb095ee1debb779c976ed63204087411d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6175726f7261776562736f6674776172652f666c6578796669656c64)](https://packagist.org/packages/aurorawebsoftware/flexyfield)[![License](https://camo.githubusercontent.com/7a5d5b15feadad1eab6a88e01cf515f908d128c49897ec8c204e30442888681f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6175726f7261776562736f6674776172652f666c6578796669656c64)](https://packagist.org/packages/aurorawebsoftware/flexyfield)

---

Ever wished you could add fields to your Laravel models without touching migrations?

**Now you can.** Welcome to FlexyField.

```
composer require aurorawebsoftware/flexyfield
php artisan migrate
```

The Magic ✨
-----------

[](#the-magic-)

```
// Give your model the power
class Product extends Model implements FlexyModelContract
{
    use Flexy;
}

// Create a schema (think of it as a "field template")
Product::createSchema('electronics', 'Electronics');
Product::addFieldToSchema('electronics', 'voltage', FlexyFieldType::STRING);
Product::addFieldToSchema('electronics', 'warranty_years', FlexyFieldType::INTEGER);

// Use it like it was always there
$tv = Product::create(['name' => 'Smart TV']);
$tv->assignToSchema('electronics');
$tv->flexy->voltage = '220V';
$tv->flexy->warranty_years = 2;
$tv->save();

// Query like a boss
Product::where('flexy_voltage', '220V')->get();
```

**No migrations. No schema changes. Just vibes.** 🎉

Why FlexyField?
---------------

[](#why-flexyfield)

ProblemOld WayFlexyField Way"We need a new product attribute"Migration + deploy + pray 🙏`addFieldToSchema()` ✅"Different products need different fields"JSON column chaos 😱Schemas! 🎯"Can we query by that custom field?"*nervous laughter*`where('flexy_field', $value)` 😎Field Types
-----------

[](#field-types)

TypeWhat it storesExample`STRING`Text`$m->flexy->color = 'blue'``INTEGER`Whole numbers`$m->flexy->stock = 42``DECIMAL`Money, measurements`$m->flexy->price = 99.99``BOOLEAN`Yes/No`$m->flexy->active = true``DATE`Dates`$m->flexy->release = '2024-01-01'``DATETIME`Timestamps`$m->flexy->created = now()``JSON`Arrays, objects`$m->flexy->tags = ['hot', 'new']``FILE`Uploads`$m->flexy->manual = $request->file('pdf')`Real-World Examples 🌍
---------------------

[](#real-world-examples-)

### E-Commerce (PIM Style)

[](#e-commerce-pim-style)

```
// Shoes have sizes and colors
Product::createSchema('footwear', 'Footwear');
Product::addFieldToSchema('footwear', 'shoe_size', FlexyFieldType::INTEGER,
    validationRules: 'required|between:35,50');
Product::addFieldToSchema('footwear', 'color', FlexyFieldType::STRING,
    fieldMetadata: ['options' => ['black', 'white', 'red', 'blue']]);

// Books have ISBNs and authors
Product::createSchema('books', 'Books');
Product::addFieldToSchema('books', 'isbn', FlexyFieldType::STRING,
    validationRules: 'required|size:13');
Product::addFieldToSchema('books', 'author', FlexyFieldType::STRING);
Product::addFieldToSchema('books', 'pages', FlexyFieldType::INTEGER);

// Same model, different fields!
$sneakers = Product::create(['name' => 'Air Max']);
$sneakers->assignToSchema('footwear');
$sneakers->flexy->shoe_size = 42;
$sneakers->flexy->color = 'black';

$novel = Product::create(['name' => 'Clean Code']);
$novel->assignToSchema('books');
$novel->flexy->isbn = '9780132350884';
$novel->flexy->author = 'Robert C. Martin';
```

### CRM (Customer Segments)

[](#crm-customer-segments)

```
// B2B customers need company info
Contact::createSchema('b2b', 'Business Customers');
Contact::addFieldToSchema('b2b', 'company_name', FlexyFieldType::STRING);
Contact::addFieldToSchema('b2b', 'employee_count', FlexyFieldType::INTEGER);
Contact::addFieldToSchema('b2b', 'annual_revenue', FlexyFieldType::DECIMAL);

// B2C customers need personal preferences
Contact::createSchema('b2c', 'Individual Customers');
Contact::addFieldToSchema('b2c', 'birthday', FlexyFieldType::DATE);
Contact::addFieldToSchema('b2c', 'interests', FlexyFieldType::JSON,
    fieldMetadata: ['options' => ['tech', 'sports', 'music', 'travel'], 'multiple' => true]);

// Query by segment
$bigCompanies = Contact::whereSchema('b2b')
    ->where('flexy_annual_revenue', '>', 1000000)
    ->get();
```

### Multi-tenant SaaS

[](#multi-tenant-saas)

```
// Each tenant can have custom fields!
$tenantSchema = "tenant_{$tenant->id}_leads";

Lead::createSchema($tenantSchema, "{$tenant->name} Leads");
Lead::addFieldToSchema($tenantSchema, 'source', FlexyFieldType::STRING);
Lead::addFieldToSchema($tenantSchema, 'score', FlexyFieldType::INTEGER);

// Tenant-specific fields added via admin panel
foreach ($tenant->customFields as $field) {
    Lead::addFieldToSchema($tenantSchema, $field->name, $field->type);
}
```

Cool Features 🎁
---------------

[](#cool-features-)

### Dropdowns &amp; Multi-select

[](#dropdowns--multi-select)

```
// Single choice
Product::addFieldToSchema('schema', 'size', FlexyFieldType::STRING,
    fieldMetadata: ['options' => ['S', 'M', 'L', 'XL']]);

// Multiple choices (use JSON type!)
Product::addFieldToSchema('schema', 'features', FlexyFieldType::JSON,
    fieldMetadata: ['options' => ['wifi', 'bluetooth', '5g'], 'multiple' => true]);

$phone->flexy->size = 'M';
$phone->flexy->features = ['wifi', '5g'];  // Array!
```

### File Uploads (with Security Baked In 🔒)

[](#file-uploads-with-security-baked-in-)

```
Product::addFieldToSchema('schema', 'manual', FlexyFieldType::FILE,
    validationRules: 'required|mimes:pdf|max:5120',
    fieldMetadata: ['disk' => 's3', 'allowed_extensions' => ['pdf']]);

$product->flexy->manual = $request->file('manual');
$product->save();

// Get URLs
$url = $product->getFlexyFileUrl('manual');
$signedUrl = $product->getFlexyFileUrlSigned('manual', now()->addHour()->timestamp);
```

### Validation (Because Data Integrity Matters)

[](#validation-because-data-integrity-matters)

```
Product::addFieldToSchema('schema', 'email', FlexyFieldType::STRING,
    validationRules: 'required|email|max:255',
    validationMessages: ['email.email' => 'Geçerli bir email girin!']);

$product->flexy->email = 'not-an-email';
$product->save();  // 💥 ValidationException!
```

### UI Hints &amp; Grouping

[](#ui-hints--grouping)

```
Product::addFieldToSchema('schema', 'battery', FlexyFieldType::INTEGER,
    label: 'Battery Capacity',
    fieldMetadata: [
        'group' => 'Technical Specs',
        'placeholder' => 'mAh',
        'hint' => 'Typical range: 3000-5000'
    ]);

// Perfect for building dynamic forms!
$schema->getFieldsGrouped();  // ['Technical Specs' => [...], 'Ungrouped' => [...]]
```

Querying 🔍
----------

[](#querying-)

```
// Simple
Product::where('flexy_color', 'blue')->get();

// Dynamic method (Laravel magic!)
Product::whereFlexyColor('blue')->get();

// By schema
Product::whereSchema('electronics')->get();
Product::whereSchemaIn(['electronics', 'furniture'])->get();

// Go wild
Product::whereSchema('electronics')
    ->where('flexy_price', 'flexy->field = 'x';  // 💥 Exception!

// Always assign first!
$product->assignToSchema('electronics');
$product->flexy->field = 'x';  // ✅

// Wrong query syntax
Product::where('flexy->field', 'x');  // 🚫 Nope

// Use underscore prefix
Product::where('flexy_field', 'x');  // ✅ Yes!
```

Performance 🚀
-------------

[](#performance-)

- **Smart view recreation** - Only rebuilds when NEW fields are added
- **Scales well** - Tested with 50+ fields, 1M+ records
- **Manual rebuild** - `php artisan flexyfield:rebuild-view`

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

[](#requirements)

- PHP 8.2+
- Laravel 11+
- MySQL 8+ or PostgreSQL 16+

Documentation
-------------

[](#documentation)

GuideWhat's Inside[Performance](docs/PERFORMANCE.md)Make it fly 🚀[Best Practices](docs/BEST_PRACTICES.md)Do it right ✅[Deployment](docs/DEPLOYMENT.md)Ship it safely 📦[Troubleshooting](docs/TROUBLESHOOTING.md)Fix it fast 🔧[File Security](docs/FILE_FIELD_SECURITY.md)Lock it down 🔒Contributing
------------

[](#contributing)

```
composer install
./vendor/bin/pest              # Run tests
./vendor/bin/phpstan analyse   # Static analysis
./vendor/bin/pint              # Code style
```

PRs welcome! 🤝

License
-------

[](#license)

MIT - Go build something awesome! 🚀

---

Made with ☕ by [Aurora Web Software](https://github.com/aurorawebsoftware)

[⭐ Star us on GitHub!](https://github.com/aurorawebsoftware/flexyfield/stargazers)

###  Health Score

47

—

FairBetter than 94% of packages

Maintenance72

Regular maintenance activity

Popularity24

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~25 days

Recently: every ~104 days

Total

19

Last Release

161d ago

Major Versions

1.6.4 → 12.0.02025-08-11

PHP version history (2 changes)1.0.0PHP ^8.2

12.0.0PHP ^8.2|^8.3|^8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/e79935c219efe1a3132a4c9f2b87da38268fccacfcb43c453275ceafdd1ed23f?d=identicon)[emreakay](/maintainers/emreakay)

---

Top Contributors

[![emreakay](https://avatars.githubusercontent.com/u/794216?v=4)](https://github.com/emreakay "emreakay (27 commits)")

---

Tags

laravelmodeldynamicattributeAuroraWebSoftwareflexyfield

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/aurorawebsoftware-flexyfield/health.svg)

```
[![Health](https://phpackages.com/badges/aurorawebsoftware-flexyfield/health.svg)](https://phpackages.com/packages/aurorawebsoftware-flexyfield)
```

###  Alternatives

[dyrynda/laravel-model-uuid

This package allows you to easily work with UUIDs in your Laravel models.

4802.8M8](/packages/dyrynda-laravel-model-uuid)[spatie/laravel-model-flags

Add flags to Eloquent models

4301.1M1](/packages/spatie-laravel-model-flags)[clickbar/laravel-magellan

This package provides functionality for working with the postgis extension in Laravel.

423715.4k1](/packages/clickbar-laravel-magellan)[lacodix/laravel-model-filter

A Laravel package to filter, search and sort models with ease while fetching from database.

17649.9k](/packages/lacodix-laravel-model-filter)[astrotomic/laravel-cachable-attributes

Allows to cache attribute accessor values in an easy way.

3240.0k](/packages/astrotomic-laravel-cachable-attributes)

PHPackages © 2026

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