PHPackages                             thescopogroup/eloquent-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. thescopogroup/eloquent-meta

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

thescopogroup/eloquent-meta
===========================

Attach meta data to Eloquent models

v2.3.0(3y ago)010.5k1MITPHPPHP &gt;=5.6.4

Since Aug 15Pushed 3y ago1 watchersCompare

[ Source](https://github.com/thescopogroup/eloquent-meta)[ Packagist](https://packagist.org/packages/thescopogroup/eloquent-meta)[ Docs](https://github.com/phoenix-labs/eloquent-meta)[ RSS](/packages/thescopogroup-eloquent-meta/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (2)Versions (26)Used By (0)

Phoenix Eloquent Meta
=====================

[](#phoenix-eloquent-meta)

[![Latest Version](https://camo.githubusercontent.com/29509f9ba66130258100549ff33e2c45c3263d01d6e5d3c6a2a3c62346138d07/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f63687269736d69636861656c7338342f656c6f7175656e742d6d6574612e7376673f7374796c653d666c61742d737175617265)](https://github.com/phoenix-labs/eloquent-meta/releases)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/1ba2cadd72f0cf9d5496b9d80db3e34c4c076d37994c06a001e8a4018c4df507/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f63687269736d69636861656c7338342f656c6f7175656e742d6d6574612f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/phoenix-labs/eloquent-meta)[![Total Downloads](https://camo.githubusercontent.com/1444e0c3f2cba2b2cbdf47e86d9a474cff031c7b5b72850cb0c6e1599ce0338b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f70686f656e69782f656c6f7175656e742d6d6574612e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/phoenix/eloquent-meta)

Attach meta data to [Laravel's](http://laravel.com/) [Eloquent models](http://laravel.com/docs/eloquent).

- Optionally create a separate table for each Model
- Use with or without Laravel
- Includes Laravel migrations or schema instructions
- Get meta or fallback

##### Which Version?

[](#which-version)

- Lavavel 5.7 - use `1.9.*`
- Laravel 5.6 - use `1.8.*`
- Laravel 5.5 - use `1.7.*`
- Laravel 5.4 - Use `1.6.*`
- Laravel 5.3 - Use `1.5.*`
- Below 5.3 - Not technically supported, but should work with `.1.3`
- Laravel 4 - Also not supported, but should work with `1.2`

##### Stable Version: 1.4.\* works with Laravel 5.\* or independently. Pulls Eloquent in automatically.

[](#stable-version-14-works-with-laravel-5-or-independently-pulls-eloquent-in-automatically)

To use for Laravel 4, see version 1.2.\*

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

[](#installation)

Install through Composer.

```
"require": {
    "phoenix/eloquent-meta": "1.6.*"
}
```

Please note only php `5.6` and `7`+ are supported.

If you are using EloquentMeta and Eloquent **without** using Laravel, you will also have to setup Eloquent as detailed in its [documentation](https://github.com/illuminate/database).

If you **are using Laravel**, then you'll want to include the ServiceProvider that will register commands and the like. Update `config/app.php` to include a reference to this package's service provider in the providers array.

```
'providers' => [
    'Phoenix\EloquentMeta\ServiceProvider'
]
```

### Table Structure

[](#table-structure)

If you are using Laravel, run the migration `php artisan vendor:publish` and `php artisan migrate` to create the database table.

If you **are not using Laravel** then you must create the table manually.

```
CREATE TABLE meta
(
    id INTEGER PRIMARY KEY NOT NULL,
    metable_id INTEGER NOT NULL,
    metable_type TEXT NOT NULL,
    key TEXT NOT NULL,
    value TEXT NOT NULL
);
CREATE UNIQUE INDEX meta_key_index ON meta (key);
CREATE UNIQUE INDEX meta_metable_id_index ON meta (metable_id);
```

Usage
-----

[](#usage)

Add the trait to all models that you want to attach meta data to:

```
use Illuminate\Database\Eloquent\Model;
use Phoenix\EloquentMeta\MetaTrait;

class SomeModel extends Model
{
    use MetaTrait;

    // model methods
}
```

Then use like this:

```
$model = SomeModel::find(1);
$model->getAllMeta();
$model->getMeta('some_key', 'optional default value'); // default value only returned if no meta found.
$model->updateMeta('some_key', 'New Value');
$model->deleteMeta('some_key');
$model->deleteAllMeta();
$model->addMeta('new_key', ['First Value']);
$model->appendMeta('new_key', 'Second Value');
```

### Unique Meta Models and Tables

[](#unique-meta-models-and-tables)

You can also define a specific meta model for a meta type. For instance, your User model can use UserMeta model with custom methods and all. Using the example above:

```
use Illuminate\Database\Eloquent\Model;
use Phoenix\EloquentMeta\MetaTrait;

class SomeModel extends Model
{
    use MetaTrait;

    protected $meta_model = 'Fully\Namespaced\SomeModelMeta';

    // model methods
}
```

Then in SomeModelMeta simply extends Phoenix\\EloquentMeta\\Meta. You may now add custom methods to the meta model. You may also dictate which table the metadata is saved to by adding

```
protected $table = "whatever_table";
```

If you are using EloquentMeta independent of Laravel, then you will have to create the database table manually.

If you are using Laravel, then include the service provider in your config/app.php

```
'providers' => [
    'Phoenix\EloquentMeta\ServiceProvider'
]
```

Then run `php artisan generate:metatable table_name` to create the migration and run `php artisan migrate` to build the table.

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

[](#contributing)

Please se \[CONTRIBUTING.md\] for more information and for testing.

### Thank you and Credits

[](#thank-you-and-credits)

Contributors

- Michael Wilson - @[chrismichaels84](http://github.com/chrismichaels84) - Maintainer
- Paweł Ciesielski - @[dzafel](http://github.com/dzafel)
- Lukas Knuth - @[LukasKnuth](http://github.com/LukasKnuth)
- @[stephandesouza](http://github.com/stephandesouza)

Many thanks to [Boris Glumpler](https://github.com/shabushabu) and [ScubaClick](https://github.com/ScubaClick) for the original package!

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 58.8% 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 ~155 days

Recently: every ~195 days

Total

21

Last Release

1191d ago

Major Versions

v1.9.0 → v2.0.02020-12-14

PHP version history (2 changes)v1.2.0PHP &gt;=5.4.0

v1.8.0PHP &gt;=5.6.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/1972316d045b029a9f04b3e30c059c1f6633722c2ef2db1b097a6a0818eafd66?d=identicon)[thescopogroup](/maintainers/thescopogroup)

---

Top Contributors

[![electricjones](https://avatars.githubusercontent.com/u/5412413?v=4)](https://github.com/electricjones "electricjones (30 commits)")[![Scuissiatto](https://avatars.githubusercontent.com/u/6907046?v=4)](https://github.com/Scuissiatto "Scuissiatto (6 commits)")[![dzafel](https://avatars.githubusercontent.com/u/765607?v=4)](https://github.com/dzafel "dzafel (4 commits)")[![thescopogroup](https://avatars.githubusercontent.com/u/66746118?v=4)](https://github.com/thescopogroup "thescopogroup (4 commits)")[![stephandesouza](https://avatars.githubusercontent.com/u/159077?v=4)](https://github.com/stephandesouza "stephandesouza (3 commits)")[![clin407](https://avatars.githubusercontent.com/u/718052?v=4)](https://github.com/clin407 "clin407 (2 commits)")[![LukasKnuth](https://avatars.githubusercontent.com/u/692211?v=4)](https://github.com/LukasKnuth "LukasKnuth (1 commits)")[![Vasiliy-Bondarenko](https://avatars.githubusercontent.com/u/5263184?v=4)](https://github.com/Vasiliy-Bondarenko "Vasiliy-Bondarenko (1 commits)")

---

Tags

laraveleloquentmeta

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/thescopogroup-eloquent-meta/health.svg)

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

###  Alternatives

[silber/bouncer

Eloquent roles and abilities.

3.6k4.4M25](/packages/silber-bouncer)[tucker-eric/eloquentfilter

An Eloquent way to filter Eloquent Models

1.8k4.8M26](/packages/tucker-eric-eloquentfilter)[watson/validating

Eloquent model validating trait.

9723.3M47](/packages/watson-validating)[kodeine/laravel-meta

Fluent Meta Data for Eloquent Models, as if it is a property on your model.

426756.0k9](/packages/kodeine-laravel-meta)[cybercog/laravel-love

Make Laravel Eloquent models reactable with any type of emotions in a minutes!

1.2k302.7k1](/packages/cybercog-laravel-love)[cviebrock/eloquent-taggable

Easy ability to tag your Eloquent models in Laravel.

567694.8k3](/packages/cviebrock-eloquent-taggable)

PHPackages © 2026

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