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

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

freshwork/metable
=================

Add metadata to your eloquent models

0.1.5(9y ago)42052MITPHP

Since Oct 7Pushed 9y ago1 watchersCompare

[ Source](https://github.com/freshworkstudio/laravel-metable)[ Packagist](https://packagist.org/packages/freshwork/metable)[ RSS](/packages/freshwork-metable/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependencies (1)Versions (8)Used By (0)

Freshwork Metable
=================

[](#freshwork-metable)

Install
-------

[](#install)

```
composer require freshwork/metable
```

Add `Freshwork\Metable\MetableServiceProvider` to your `app.php` config file

```
'providers' => [
    ...
    Freshwork\Metable\MetableServiceProvider::class
]
```

Run laravel migrations to install `metas` table on your database

```
php artisan migrate
```

Usage
-----

[](#usage)

Add `Freshwork\Metable\Traits\Metable` trait to your eloquent model

```
namespace App;

use Freshwork\Metable\Traits\Metable;

class Post extends Model {
    use Metable;
    ...
}
```

#### Add meta

[](#add-meta)

By the moment, addMeta inmediately executes a sql query to save.

```
$post->addMeta('key', 'value');
$post->addMeta('foo', ['bar', 'baz']); //saved as json
$post->addMeta('third', 'value1');
$post->addMeta('third', 'value2');
```

#### Get meta

[](#get-meta)

Remember that you can add multiple meta for the same key, so by default, `getMeta()` returns an array, even if there are just one value for that key. You can use the `single` param to get the first value directly

`getMeta($key, $single = false, $cacheAll = true)`

Eager loading: If `$cacheAll` is set to true, when you getMeta you retrieve all the metas of the model, so the next `getMeta` call don't touch the database.

```
$post->getMeta('key'); // ['value']
$post->getMeta('foo'); // [ ['bar', 'baz'] ]
$post->getMeta('third'); // [ 'value1', 'values2' ]

//If you want to get the first element of the array
$post->getMeta('key', true); // 'value'
$post->getMeta('foo', true); // ['bar', 'baz']
$post->getMeta('third', true); // 'value1'
```

#### Get all meta

[](#get-all-meta)

```
//Load $post->metadata variable
$post->loadMeta();

//Then you can
dd($post->metadata->key); //['value']
```

#### Remove meta

[](#remove-meta)

```
//Load $post->metadata variable
$post->removeMeta('key'); //remove all the ocurrences of metas with that key in the current model
```

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

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

Every ~0 days

Total

6

Last Release

3554d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/954524bc2e96e26c6670b60375e0ed3759db6862e1d2721a074c74f92ef9a070?d=identicon)[gonzunigad](/maintainers/gonzunigad)

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

### Embed Badge

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

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

###  Alternatives

[backpack/crud

Quickly build admin interfaces using Laravel, Bootstrap and JavaScript.

3.4k3.7M220](/packages/backpack-crud)[anourvalar/eloquent-serialize

Laravel Query Builder (Eloquent) serialization

11223.5M33](/packages/anourvalar-eloquent-serialize)[statamic-rad-pack/runway

Eloquently manage your database models in Statamic.

135224.7k7](/packages/statamic-rad-pack-runway)[mozex/laravel-scout-bulk-actions

Import, flush, and queue-import all your Laravel Scout searchable models at once. Auto-discovers models, runs in bulk, tracks progress.

1539.3k](/packages/mozex-laravel-scout-bulk-actions)[ramadan/easy-model

A Laravel package for enjoyably managing database queries.

111.6k](/packages/ramadan-easy-model)

PHPackages © 2026

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