PHPackages                             digitalruby/meta-data - 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. digitalruby/meta-data

ActiveLibrary

digitalruby/meta-data
=====================

Adds a flexible key/value table to your Laravel models

1.0.0(2y ago)314MITPHPPHP ^8.0

Since Feb 24Pushed 2y ago1 watchersCompare

[ Source](https://github.com/pvdptje/MetaData)[ Packagist](https://packagist.org/packages/digitalruby/meta-data)[ RSS](/packages/digitalruby-meta-data/feed)WikiDiscussions master Synced 1mo ago

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

DigitalRuby/MetaData
====================

[](#digitalrubymetadata)

Adds a flexible key/value table to your Laravel models.

Why this package?
-----------------

[](#why-this-package)

I often find myself needing to store extra bits of information across entities in my apps. This could be a github link, maybe a SEO title or a path to a file.

Instead of expanding my database with new fields across multiple entities, I often resort back to a simple `key value table` that has a `polymorphic relationship` to any entity.

This package provides you with that table and a `trait` that you can add to your models to implement the functionality.

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

[](#installation)

To install the package, use Composer:

```
composer require digitalruby/meta-data
```

After installing, you should run the migration to create the `meta_data` table in your database:

```
php artisan migrate
```

This command creates the necessary table for storing meta data related to your models.

Usage
-----

[](#usage)

1. **Add the Trait to Your Model:**

    First, include the `HasMetaData` trait in any Eloquent model you wish to associate meta data with.

    ```
    use DigitalRuby\MetaData\HasMetaData;

    class YourModel extends Model {
        use HasMetaData;

        // Model content
    }
    ```
2. **Setting Meta Data:**

    To add or update meta data for a model, use the `setMeta` method.

    ```
    $model->setMeta('key', 'value');
    ```

    - `key`: The meta data key.
    - `value`: The meta data value. Can be a string, array, or object. Arrays and objects are automatically encoded to JSON.
3. **Getting Meta Data:**

    Retrieve a value with the `getMeta` method.

    ```
    $value = $model->getMeta('key');
    ```

    Optionally, you can retrieve all meta data associated with the model:

    ```
    $allMeta = $model->getAllMeta();
    ```
4. **Deleting Meta Data:**

    To remove a meta data entry, use `deleteMeta`.

    ```
    $model->deleteMeta('key');
    ```

    This will delete the meta data entry with the specified key.
5. **Advanced Usage:**

    The `getMeta` method supports additional query modifications via a callback function, allowing for more complex queries.

Requirements
------------

[](#requirements)

- PHP 8 or higher
- Laravel 10 or higher

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

[](#contributing)

We welcome contributions! Please submit pull requests for bug fixes, features, or improvements.

License
-------

[](#license)

The DigitalRuby/MetaData package is open-sourced software licensed under the MIT license.

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity46

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

Unknown

Total

1

Last Release

814d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e8f98d76b638a1fee5474073d848b353abf9f6682c398b009e8385585e93f8ca?d=identicon)[digitalruby](/maintainers/digitalruby)

### Embed Badge

![Health badge](/badges/digitalruby-meta-data/health.svg)

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

###  Alternatives

[fumeapp/modeltyper

Generate TypeScript interfaces from Laravel Models

196277.9k](/packages/fumeapp-modeltyper)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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