PHPackages                             glugox/model-meta - 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. glugox/model-meta

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

glugox/model-meta
=================

Laravel package for defining model fields, validation, relations, etc.

v1.1.6(8mo ago)02592MITPHPPHP ^8.2

Since Sep 14Pushed 8mo agoCompare

[ Source](https://github.com/glugox/model-meta)[ Packagist](https://packagist.org/packages/glugox/model-meta)[ RSS](/packages/glugox-model-meta/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (4)Versions (9)Used By (2)

ModelMeta
=========

[](#modelmeta)

[![PHP Version](https://camo.githubusercontent.com/504ead6a583c68d8d62d7bfceed24e569ca613d7a36bed380281b3455b5c7b31/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e342d626c7565)](https://www.php.net)[![License](https://camo.githubusercontent.com/8bb50fd2278f18fc326bf71f6e88ca8f884f72f179d3e555e20ed30157190d0d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e2e737667)](LICENSE)

**ModelMeta** is a PHP package to define metadata for models, including fields, types, validation rules, and relationships.

---

Features
--------

[](#features)

- Define model fields with **type-safe classes** (`TextField`, `EmailField`, `EnumField`, etc.)
- Fluent API for setting **validation rules**, `nullable`, `required`, `default`, `sortable`, `unique` and more
- Supports numeric ranges (`min`, `max`) and precision (`step`) for decimal/float fields
- Explicit **enum values** support
- Controls for **visibility** in forms and tables (`showInForm`, `showInTable`)
- Readonly and hidden field flags
- Integration-ready for custom admin panels or CRUD generators
- Ready for automated tests with Pest

---

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

[](#installation)

```
composer require glugox/model-meta
```

---

Basic Usage
-----------

[](#basic-usage)

```
use Glugox\ModelMeta\Fields\Text;
use Glugox\ModelMeta\Fields\Email;
use Glugox\ModelMeta\Fields\Enum;
use Glugox\ModelMeta\Fields\Decimal;
use Glugox\ModelMeta\FieldType;

class UserMeta
{
    public function fields(): array
    {
        return [
            Text::make('first_name')->required()->sortable(),
            Text::make('last_name')->nullable(),
            Email::make('email')->required(),
            Enum::make('role', ['admin', 'editor', 'user']),
            Decimal::make('balance')->default(0)->step(0.01)->min(0),
        ];
    }
}
```

---

Fluent API Example
------------------

[](#fluent-api-example)

```
use Glugox\ModelMeta\Fields\Text;

$field = Text::make('username')
    ->required()
    ->nullable() // automatically adds 'nullable' rule
    ->default('guest')
    ->sortable()
    ->unique('users', 'username');
```

---

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

[](#field-types)

Supported field types include:

- Basic: `ID`, `String`, `Text`, `LongText`, `MediumText`, `Char`
- Numbers: `Integer`, `SmallInteger`, `TinyInteger`, `BigInteger`, `Decimal`, `Float`, `Double`
- Special: `Email`, `Password`, `Phone`, `Username`, `Slug`, `URL`, `UUID`, `Token`, `Secret`
- Date/Time: `Date`, `DateTime`, `Time`, `Timestamp`, `Year`
- Boolean / Binary: `Boolean`, `Binary`
- File: `File`, `Image`
- JSON: `JSON`, `JSONB`
- Enumeration: `Enum` (with values)

---

Relations
---------

[](#relations)

Currently supports:

- `BelongsTo`
- `HasOne`
- `HasMany`
- `BelongsToMany`

Define relations via dedicated relation classes when building meta for entities.

---

Testing
-------

[](#testing)

Pest is recommended:

```
composer require pestphp/pest --dev
```

Example test:

```
use Dummies\UserMeta;
use Glugox\ModelMeta\FieldType;

it('defines UserMeta fields', function () {
    $meta = new UserMeta();
    $fields = $meta->fields();

    expect($fields)->toHaveCount(5)
        ->and($fields[0]->type)->toBe(FieldType::STRING)
        ->and($fields[0]->required)->toBeTrue();
});
```

---

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

[](#contributing)

Contributions are welcome! Please open issues or pull requests.

---

License
-------

[](#license)

MIT License. See [LICENSE](LICENSE) file for details.

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance60

Regular maintenance activity

Popularity11

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 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 ~5 days

Total

8

Last Release

256d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/13313019?v=4)[Glugox](/maintainers/glugox)[@glugox](https://github.com/glugox)

---

Top Contributors

[![glugox](https://avatars.githubusercontent.com/u/13313019?v=4)](https://github.com/glugox "glugox (16 commits)")

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/glugox-model-meta/health.svg)

```
[![Health](https://phpackages.com/badges/glugox-model-meta/health.svg)](https://phpackages.com/packages/glugox-model-meta)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[laravel/mcp

Rapidly build MCP servers for your Laravel applications.

77022.3M151](/packages/laravel-mcp)[api-platform/laravel

API Platform support for Laravel

58171.4k14](/packages/api-platform-laravel)[intervention/image-laravel

Laravel Integration of Intervention Image

1588.9M182](/packages/intervention-image-laravel)[fleetbase/core-api

Core Framework and Resources for Fleetbase API

1235.9k20](/packages/fleetbase-core-api)

PHPackages © 2026

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