PHPackages                             jaybizzle/hasmeta - 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. jaybizzle/hasmeta

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

jaybizzle/hasmeta
=================

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

v0.1.3(11y ago)291.9k4[1 issues](https://github.com/JayBizzle/hasmeta/issues)MITPHPPHP &gt;=5.4.0

Since Oct 15Pushed 11y ago7 watchersCompare

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

READMEChangelog (4)Dependencies (1)Versions (5)Used By (0)

HasMeta
=======

[](#hasmeta)

A Laravel trait to access model meta data as if it was a property on your model

[![Latest Stable Version](https://camo.githubusercontent.com/ba8af442596f7da5513e710341cd071e047cfa68cf74697af1c5d67e9817c361/68747470733a2f2f706f7365722e707567782e6f72672f6a617962697a7a6c652f6861736d6574612f762f737461626c652e737667)](https://packagist.org/packages/jaybizzle/hasmeta) [![Total Downloads](https://camo.githubusercontent.com/18a8cb2e91e55a5ba42bf5f31d2f802f382a3269959c9859f27026032ceadca8/68747470733a2f2f706f7365722e707567782e6f72672f6a617962697a7a6c652f6861736d6574612f646f776e6c6f616473)](https://packagist.org/packages/jaybizzle/hasmeta) [![Latest Unstable Version](https://camo.githubusercontent.com/07f9632422a71b1aed09d68e98d2905428e410454fd7b008ad9cfa211d4ee357/68747470733a2f2f706f7365722e707567782e6f72672f6a617962697a7a6c652f6861736d6574612f762f756e737461626c652e737667)](https://packagist.org/packages/jaybizzle/hasmeta) [![License](https://camo.githubusercontent.com/7c8ebd0f37501e9313b083875e60a3f5543ceb6d8e3ae86d440ab7036eca77d2/68747470733a2f2f706f7365722e707567782e6f72672f6a617962697a7a6c652f6861736d6574612f6c6963656e73652e737667)](https://packagist.org/packages/jaybizzle/hasmeta)

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

[](#installation)

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

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

```
	use Jaybizzle\Hasmeta\HasMetaTrait;

	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

`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 Jaybizzle\Hasmeta\HasMetaTrait;

	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

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();
```

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 94.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 ~2 days

Total

4

Last Release

4226d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/340752?v=4)[Mark Beech](/maintainers/JayBizzle)[@JayBizzle](https://github.com/JayBizzle)

---

Top Contributors

[![JayBizzle](https://avatars.githubusercontent.com/u/340752?v=4)](https://github.com/JayBizzle "JayBizzle (32 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/jaybizzle-hasmeta/health.svg)

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

###  Alternatives

[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)
