PHPackages                             nguyentranchung/laravel-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. nguyentranchung/laravel-metable

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

nguyentranchung/laravel-metable
===============================

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

66PHP

Since Nov 19Pushed 7y ago1 watchersCompare

[ Source](https://github.com/nguyentranchung/laravel-metable)[ Packagist](https://packagist.org/packages/nguyentranchung/laravel-metable)[ RSS](/packages/nguyentranchung-laravel-metable/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (1)Used By (0)

Fluent Meta Data for Eloquent Models
====================================

[](#fluent-meta-data-for-eloquent-models)

Metable Trait adds the ability to access meta data as if it is a property on your model. Metable is Fluent, just like using an eloquent model attribute you can set or unset metas. Follow along the documentation to find out more.

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

[](#installation)

### Composer

[](#composer)

```
composer require nguyentranchung/laravel-metable
```

### Migration

[](#migration)

```
php artisan vendor:publish --provider=NguyenTranChung\Metable\MetableServiceProvider --tag=migrations
```

### Configuration

[](#configuration)

```
php artisan vendor:publish --provider=NguyenTranChung\Metable\MetableServiceProvider --tag=config
```

### Model Setup

[](#model-setup)

```
use NguyenTranChung\Metable\Metable\Metable;
use NguyenTranChung\Metable\Metable\MetableTrait;

class Post extends Model implements Metable
{
    // ...
    use MetableTrait;
}
```

Usage
-----

[](#usage)

### Add Meta

[](#add-meta)

```
$post = Post::first();
// add single meta
$post->setMeta('key0', 'value0');
$post->setMeta('key1', 'value1');
// add multi metas
$post->setMeta([
    'key2' => 'value2',
    'key3' => 'value3',
    'key4' => 'value4',
]);
// auto save meta
$post->save();
// or
$post->updateOrCreateMetas();
```

### Delete Meta

[](#delete-meta)

```
// unset single meta key
$post->unsetMeta('key0');
// unset multi meta key
$post->unsetMeta(['key1', 'key2', 'key3']);
// auto save change meta
$post->save();
// or
$post->deleteMetas();

// Delete all metas
$post->deleteAllMetas();
```

### Get Meta

[](#get-meta)

```
// get all metas
$post->getMeta();

// get meta with key
$post->getMeta('key1');

// get multi meta with keys
$post->getMeta(['key1', 'key2', 'key3']);

// Get value of key, only string key input
$post->getMetaValue('key1');
```

Eager Loading
-------------

[](#eager-loading)

When you need to retrive multiple results from your model, you can eager load `metas`

```
$post = Post::with(['metas'])->get();
```

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 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.

### Community

Maintainers

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

---

Top Contributors

[![nguyentranchung](https://avatars.githubusercontent.com/u/9611224?v=4)](https://github.com/nguyentranchung "nguyentranchung (11 commits)")

### Embed Badge

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

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

###  Alternatives

[components/jqueryui

jQuery UI is a curated set of user interface interactions, effects, widgets, and themes built on top of the jQuery JavaScript Library. Whether you're building highly interactive web applications or you just need to add a date picker to a form control, jQuery UI is the perfect choice.

1795.8M57](/packages/components-jqueryui)

PHPackages © 2026

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