PHPackages                             astritzeqiri/laravel-metadata - 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. astritzeqiri/laravel-metadata

ActiveLaravel-plugin[Utility &amp; Helpers](/categories/utility)

astritzeqiri/laravel-metadata
=============================

Add metadata to laravel models

1.0.8(9y ago)4350MITPHPPHP &gt;=5.4.0

Since Jul 27Pushed 8y ago2 watchersCompare

[ Source](https://github.com/astritzeqiri/laravel-metadata)[ Packagist](https://packagist.org/packages/astritzeqiri/laravel-metadata)[ Docs](https://github.com/astritzeqiri/laravel-metadata)[ RSS](/packages/astritzeqiri-laravel-metadata/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (1)Versions (10)Used By (0)

Laravel Meta data
=================

[](#laravel-meta-data)

Add metadata to laravel models

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

[](#requirements)

- PHP &gt;=5.4
- Laravel &gt;= 5.0

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

[](#installation)

Add laravel-metadata to your composer.json file:

```
"require": {
    "astritzeqiri/laravel-metadata": "~1.0"
}
```

Get composer to install the package:

```
$ composer require astritzeqiri/laravel-metadata

```

### Registering the Package

[](#registering-the-package)

Register the service provider within the `providers` array found in `app/config/app.php`:

```
'providers' => array(
    // ...
    AstritZeqiri\Metadata\LaravelMetaDataServiceProvider::class
)
```

If you want you can add an alias to the MetaData model within the `aliases` array found in `app/config/app.php`:

```
'aliases' => array(
    // ...
    'MetaData' => AstritZeqiri\Metadata\Models\MetaDada::class,
)
```

Then you need to publish the migration files:

```
$ php artisan vendor:publish --provider="AstritZeqiri\Metadata\LaravelMetaDataServiceProvider"

```

And then run the migration:

```
$ php artisan migrate

```

Usage
=====

[](#usage)

Basic Examples
--------------

[](#basic-examples)

First you need to go to your model and use the HasManyMetaDataTrait:

```
// E.x. User.php
// add this before the class declaration
use AstritZeqiri\Metadata\Traits\HasManyMetaDataTrait;

// after the class declaration add this code snippet:
use HasManyMetaDataTrait;
```

### Updating a meta data entry:

[](#updating-a-meta-data-entry)

```
// get the instance
$user = \App\User::first();

// update a metadata if it exists else add a new one
$user->update_meta("meta_key", "meta_value");
```

### Get meta data entry:

[](#get-meta-data-entry)

```
// get the instance
$user = \App\User::first();

// get a metadata object with a given key
$user->get_meta("meta_key");

// if the second parameter is true it returns only the value
$user->get_meta("meta_key", true);
```

### Delete meta data entry:

[](#delete-meta-data-entry)

```
// get the instance
$user = \App\User::first();

// delete a metadata entry with a given key
$user->delete_meta("meta_key");

// delete all metadatas of a user
$user->delete_all_metas();
```

### Filter users by meta\_data:

[](#filter-users-by-meta_data)

```
// Search by only one meta data.
$users = \App\User::metaQuery('hair_color', 'red')->get();
// filter the users that have red hair color

// Search by many meta data.
$users = \App\User::metaQuery(array(
	array('key' => 'hair_color', 'value' => 'red'),
	array('key' => 'phone_number', 'value' => '%111%', 'compare' => "LIKE")
), "OR")->get();
// filter the users that have red hair color
// or that their phone_number contains '111'
```

License
-------

[](#license)

[MIT](http://opensource.org/licenses/MIT)

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 96.8% 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 ~27 days

Recently: every ~1 days

Total

9

Last Release

3405d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/8720176?v=4)[Astrit Zeqiri](/maintainers/astritzeqiri)[@astritzeqiri](https://github.com/astritzeqiri)

---

Top Contributors

[![astritzeqiri](https://avatars.githubusercontent.com/u/8720176?v=4)](https://github.com/astritzeqiri "astritzeqiri (30 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (1 commits)")

---

Tags

eloquent-metadatalaravellaravel-metadatametadatalaravelmetameta data

### Embed Badge

![Health badge](/badges/astritzeqiri-laravel-metadata/health.svg)

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

###  Alternatives

[markwalet/nova-modal-response

A Laravel Nova asset for Modal responses on an action.

17818.7k](/packages/markwalet-nova-modal-response)[lionix/seo-manager

SEO Manager for Laravel Framework

2145.4k](/packages/lionix-seo-manager)[nickurt/laravel-akismet

Akismet for Laravel 11.x/12.x/13.x

98145.2k3](/packages/nickurt-laravel-akismet)[creasi/laravel-nusa

A Laravel package that aim to provide Indonesia' Administrative Data

997.7k2](/packages/creasi-laravel-nusa)[team-nifty-gmbh/tall-datatables

Server-side rendered datatables for Laravel and Livewire

1319.7k3](/packages/team-nifty-gmbh-tall-datatables)[tomshaw/electricgrid

A feature-rich Livewire package designed for projects that require dynamic, interactive data tables.

119.2k](/packages/tomshaw-electricgrid)

PHPackages © 2026

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