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

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

royalcms/metable
================

The Royalcms metable package.

v5.1.0(5y ago)0581MITPHPPHP &gt;=5.5.9

Since Sep 4Pushed 5y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (3)Used By (1)

Royalcms-Metable
================

[](#royalcms-metable)

Royalcms-Metable is a package for easily attaching arbitrary data to Eloquent models for Royalcms 5.

Features
--------

[](#features)

- One-to-many polymorphic relationship allows attaching data to Eloquent models without needing to adjust the database schema.
- Type conversion system allows data of numerous different scalar and object types to be stored and retrieved. See the documentation for the list of supported types.

Example Usage
-------------

[](#example-usage)

Attach some metadata to an eloquent model

```
$post = Post::create($this->request->input());
$post->setMeta('color', 'blue');
```

Query the model by its metadata

```
$post = Post::whereMeta('color', 'blue');
```

Retrieve the metadata from a model

```
$value = $post->getMeta('color');
```

Add the `Royalcms\Component\Metable\Metable` trait to any eloquent model class that you want to be able to attach metadata to.

```
