PHPackages                             leemason/metable - 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. leemason/metable

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

leemason/metable
================

The Laravel Eloquent Metable Package is designed specifically for associating meta information to an Eloquent model.

1.0.0(10y ago)313[1 issues](https://github.com/leemason/metable/issues)MITPHP

Since Oct 31Pushed 10y ago1 watchersCompare

[ Source](https://github.com/leemason/metable)[ Packagist](https://packagist.org/packages/leemason/metable)[ RSS](/packages/leemason-metable/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

Laravel Metable Package
-----------------------

[](#laravel-metable-package)

[![Packagist License](https://camo.githubusercontent.com/bb3ad08c5c79ba20361166238d831577c0f51a1c98dd784be0dd0186dd1f37e6/68747470733a2f2f706f7365722e707567782e6f72672f6c65656d61736f6e2f6d657461626c652f6c6963656e73652e706e67)](http://choosealicense.com/licenses/mit/)[![Latest Stable Version](https://camo.githubusercontent.com/a1b85db6929b33f6c3540c2a2995a37e372dec3c350f1d0eef6812b7c82aee6a/68747470733a2f2f706f7365722e707567782e6f72672f6c65656d61736f6e2f6d657461626c652f76657273696f6e2e706e67)](https://packagist.org/packages/leemason/metable)[![Total Downloads](https://camo.githubusercontent.com/7d3e9e187d245c6d5c7f941417688aac81b197c2ba017ab0df02e40a1db61c09/68747470733a2f2f706f7365722e707567782e6f72672f6c65656d61736f6e2f6d657461626c652f642f746f74616c2e706e67)](https://packagist.org/packages/leemason/metable)[![Build Status](https://camo.githubusercontent.com/c37b2e920bd16fd1423100aadd0bea23cfe8530c851edce38e27ef74865c5089/68747470733a2f2f7472617669732d63692e6f72672f6c65656d61736f6e2f6d657461626c652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/leemason/metable)

The Laravel Eloquent Metable Package is designed specifically for associating "meta" information to an Eloquent model.

### Installation

[](#installation)

Just place require new package for your laravel installation via composer.json

```
composer require leemason/metable

```

Then hit composer update

### Compatability

[](#compatability)

The Metable package has been developed with Laravel 5.1, i see no reason why it wouldnt work with 5.0 or even 4 but it is only tested for 5.1.

### Introduction

[](#introduction)

There are many use cases for this, most notably a User model where you may need the ability to assign multiple different types of profile information.

Ideally you would always provide unique columns on your model tables to handle all of the data, but in more dynamic applications this may not always be a viable option.

This is were "meta" information comes into its own.

This package provides the means to associate any kind of data to a model, from ints, float, bools, arrays, to Collections and objects.

Not only does it make it easy to assign this data, it also formats the data for the database and on return usage.

For example a User may need multiple social links, with this package you can create a collection with the data, save right there and then as a Collection (which gets saved as json encoded string). Then whenever its retrieved in the future it will be converted back to a Collection.

The "meta" is saved as related Eloquent models with simple key/value access.

In the background the meta model also saved the values "type" for use when returning.

The package comes with 2 traits which adds all the functionality needed and a few helpers to make managing the information even easier.

The `Metable` trait is used to turn an Eloquent model into a meta model and provides all the background logic for formatting the meta value.

Then the main functionality is accessed through the `HasMeta` trait.

Here are a few examples (checkout the docs folder for more details information).

```
class User extends Eloquent{
    use LeeMason\Metable\HasMeta;

    protected $metaModel = 'UserMeta';
}

class UserMeta extends LeeMason\Metable\MetaModel{
    // By extending the MetaModel we dont have to set the $fillable or $casts properties!
    // Or you can just use the trait
}

$user = new User();

// uses Eloquent firstOrNew to either create or fetch/update the field by "key"
$user->addMeta('key', 'value');

// simple wrapper around addMeta for readability
$user->updateMeta('collection', new Collection(['collection', 'items']));

// need to save lots of data? not a problem
$user->fillMeta([
    'meta1' => true,
    'meta2' => 200,
    'meta3' => [1,2,3],
    ....
]);

// deleting is easy too
$user->deleteMeta('meta2');

// this will return a Collection object
$collection = $user->getMeta('collection');

// and of course, the meta data are related models so can be accessed, or set as such too
$user->meta();

//or
$user->meta

//and
$meta = new UserMeta();
$meta->key = 'thekey';
$meta->value = 'some value';
$user->meta()->save($meta);
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance13

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity63

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

Unknown

Total

1

Last Release

3852d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0b8fdb3cf22dac46100ad95eddb94f98b2a7a5002b29c4d2f812113f2867ff35?d=identicon)[leemason](/maintainers/leemason)

---

Top Contributors

[![leemason](https://avatars.githubusercontent.com/u/1238646?v=4)](https://github.com/leemason "leemason (14 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/leemason-metable/health.svg)

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

###  Alternatives

[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)[clickbar/laravel-magellan

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

423715.4k1](/packages/clickbar-laravel-magellan)[genealabs/laravel-pivot-events

This package introduces new eloquent events for sync(), attach(), detach() or updateExistingPivot() methods on BelongsToMany relation.

1404.9M8](/packages/genealabs-laravel-pivot-events)[reedware/laravel-relation-joins

Adds the ability to join on a relationship by name.

2121.2M13](/packages/reedware-laravel-relation-joins)[aglipanci/laravel-eloquent-case

Adds CASE statement support to Laravel Query Builder.

115157.2k](/packages/aglipanci-laravel-eloquent-case)

PHPackages © 2026

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