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

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

jlopezcur/metable
=================

Access model meta data as if it was a property on your model (Fork based on the work of https://github.com/Azirius/hasmeta) for Laravel 5

v0.1.4(10y ago)121MITPHPPHP &gt;=5.3.0

Since Oct 15Pushed 10y ago1 watchersCompare

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

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

Metable
=======

[](#metable)

A Laravel trait to access model meta data as if it was a property on your model (Fork based on the work of ) for Laravel 5

Installation
============

[](#installation)

Run `composer require jlopezcur/metable 0.1.*` or add `"jlopezcur/metable": "0.1.*"` to your `composer.json` file

In the Model that you want to utilise `Metable` add the following properties

```
	use Jlopezcur\Metable\MetableTrait;

	protected $meta_model       = 'ModelName'; // the name of your meta data model
	protected $meta_foreign_key = 'user_id'; // the foreign key of your main model
	protected $meta_primary_key = 'meta_id'; // the primary key of you meta data model
	protected $meta_key_name    = 'dataName'; // the column name that stores your meta data key name
	protected $meta_value_name  = 'dataValue'; // the column name that stores your meta data value
```

Real World Example
==================

[](#real-world-example)

Nothing like a simple example to explain things

### Setup

[](#setup)

`users` table

idemailpassword1ADpQeKh$2y$10$0dh/BerzTrEOBhu4SR3w052pQeKhrzTrEOBhu$2y$10$0dh/BeAD4SR3w053ADpQeKhrzTrEOBhu4SR3w05$2y$10$0dh/Be4BeADpQeKhrzTrEO$2y$10$0dh/Bhu4SR3w055DpQeKhrzTrEOBhu4SR3w05$2y$10$0dh/BeA`users_meta` table

iduser\_idmeta\_namemeta\_value11first\_nameJohn21surnameRoberts31age2041genderMale52first\_nameSteven62surnameWatson72age3582genderMale93first\_nameSam103surnameFaddy113age30123genderFemale134first\_nameBen144surnameProkop154age32164genderMale175first\_nameJo185surnameBlair195age31205genderFemale`User.php` model

```
class User extends Eloquent {

	use Jlopezcur\Metable\MetableTrait;

	protected $meta_model       = 'UserMeta';
	protected $meta_foreign_key = 'user_id';
	protected $meta_primary_key = 'id';
	protected $meta_key_name    = 'meta_name';
	protected $meta_value_name  = 'meta_value';

	/**
	 * The database table used by the model.
	 *
	 * @var string
	 */
	protected $table = 'users';

	/**
	 * The primary key on the table
	 *
	 * @var string
	 */
	protected $primaryKey = 'id';

	// ...
}
```

`UserMeta.php` model

```
class UserMeta extends Eloquent {

	/**
	 * The database table used by the model.
	 *
	 * @var string
	 */
	protected $table = 'users_meta';

	/**
	 * The primary key on the table
	 *
	 * @var string
	 */
	protected $primaryKey = 'id';

	// ...
}
```

### Usage

[](#usage)

Now we can simply do this for getting meta data...

```
$user = User::find(1);
echo $user->gender; // Will output 'Male'
```

We can save meta data easily too...

```
$user = User::find(1);
$user->gender = 'Female';
$user->save();
```

Delete meta...

```
$user = User::find(1);
$user->gender = null;
$user->save();
```

New meta...

```
$user = User::find(1);
$user->anything_you_want = 'some lovely value';
$user->save();
```

Mass assignment...

```
$user = User::find(1);
$user->fill($request->input())->save();
$user->save();
```

For mass assignment Remember add in your model...

```
protected $guarded = array();
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 82.1% 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

Every ~73 days

Total

5

Last Release

3939d ago

PHP version history (2 changes)v0.1.0PHP &gt;=5.4.0

v0.1.4PHP &gt;=5.3.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/467d3532385466b6e4c20c4963769fd64b5ef2c935aed669f909ad337aa0a5b7?d=identicon)[jlopezcur](/maintainers/jlopezcur)

---

Top Contributors

[![JayBizzle](https://avatars.githubusercontent.com/u/340752?v=4)](https://github.com/JayBizzle "JayBizzle (32 commits)")[![jlopezcur](https://avatars.githubusercontent.com/u/4610342?v=4)](https://github.com/jlopezcur "jlopezcur (5 commits)")[![GC-Mark](https://avatars.githubusercontent.com/u/1477806?v=4)](https://github.com/GC-Mark "GC-Mark (1 commits)")[![samuelcasas](https://avatars.githubusercontent.com/u/1270065?v=4)](https://github.com/samuelcasas "samuelcasas (1 commits)")

---

Tags

laraveldatakeymetavalue

### Embed Badge

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

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

###  Alternatives

[jaybizzle/hasmeta

Access model meta data as if it was a property on your model

291.9k](/packages/jaybizzle-hasmeta)[zoha/laravel-meta

a package for working with models meta

236121.7k](/packages/zoha-laravel-meta)[torann/laravel-meta-tags

A package to manage Header Meta Tags

65273.3k4](/packages/torann-laravel-meta-tags)[lionix/seo-manager

SEO Manager for Laravel Framework

2165.4k](/packages/lionix-seo-manager)[xefi/faker-php-laravel

Faker php integration with laravel

1915.1k](/packages/xefi-faker-php-laravel)[fomvasss/laravel-meta-tags

A package to manage SEO (meta-tags, xml-fields, etc.)

3028.9k](/packages/fomvasss-laravel-meta-tags)

PHPackages © 2026

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