PHPackages                             davidwesdijk/laravel-polymorphic-eav - 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. [Database &amp; ORM](/categories/database)
4. /
5. davidwesdijk/laravel-polymorphic-eav

ActiveLibrary[Database &amp; ORM](/categories/database)

davidwesdijk/laravel-polymorphic-eav
====================================

Integrate the entity-attribute-value model with polymorphic Eloquent-relations in your Laravel application.

1.0.6(4y ago)61.8k4[2 issues](https://github.com/davidwesdijk/laravel-polymorphic-eav/issues)[1 PRs](https://github.com/davidwesdijk/laravel-polymorphic-eav/pulls)MITPHPPHP ^7.1|^8.0CI failing

Since Jul 21Pushed 4y ago1 watchersCompare

[ Source](https://github.com/davidwesdijk/laravel-polymorphic-eav)[ Packagist](https://packagist.org/packages/davidwesdijk/laravel-polymorphic-eav)[ Docs](https://github.com/davidwesdijk/laravel-polymorphic-eav)[ RSS](/packages/davidwesdijk-laravel-polymorphic-eav/feed)WikiDiscussions master Synced yesterday

READMEChangelog (6)Dependencies (3)Versions (8)Used By (0)

Polymorphic EAV-model integration
=================================

[](#polymorphic-eav-model-integration)

[![Latest Version on Packagist](https://camo.githubusercontent.com/184f9dfa8a2a55d3edbb86cead8e2bfdf3ba91cf4e7e84651a320a9e3be5815a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f646176696477657364696a6b2f6c61726176656c2d706f6c796d6f72706869632d6561762e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/davidwesdijk/laravel-polymorphic-eav)[![Total Downloads](https://camo.githubusercontent.com/085c740f7e7a42c0cdde9e70939d42360299ff39245598d884df766747ecb9c1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f646176696477657364696a6b2f6c61726176656c2d706f6c796d6f72706869632d6561762e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/davidwesdijk/laravel-polymorphic-eav)

Integrate the entity-attribute-value model with polymorphic Eloquent-relations in your Laravel application.

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

[](#installation)

You can install the package via composer:

```
composer require davidwesdijk/laravel-polymorphic-eav
```

Usage
-----

[](#usage)

### Preparing your models

[](#preparing-your-models)

In order to implement the Entity-Attribute-Value-model to your Eloquent models, the only required action is to add the `HasEntityAttributeValues` Trait. That's all action required to use the full features this package brings.

```
use DavidWesdijk\LaravelPolymorphicEav\Traits\HasEntityAttributeValues;

class Product extends Model
{
     use HasEntityAttributeValues;

    // Implementation of your Eloquent model
}
```

### Assigning attributes

[](#assigning-attributes)

Attributes are, when the Trait is added, accessable and assignable by the `props` accessor on your Eloquent Model. Just set its value!

```
class ProductController extends Controller
{
    public function update(AnyValidatedRequest $request, Product $product)
    {
        $product->props->details->color = $request->color; // E.g. 'red'

        // That's it!
    }
}
```

### Accessing attributes

[](#accessing-attributes)

The assigned attributes are simply accessible by defining the group and the attribute in the `props` accessor like the following example. The concept is that all required properties must be accessible, without throwing exceptions, to keep you code clean, readable and maintainable.

```
// This attribute has been set before
$product->props->details->color; // 'red'

// This attribute has never been set before
$product->props->details->sku; // null

// Even if the group has never been defined
$product->props->foo->bar; // null
```

### Other functionality

[](#other-functionality)

If you'd like e.g. remove a property you can either set it's value to null, or you can simply unset the value. The database entry will be removed.

```
unset($product->props->details->color);

$product->props->details->color; // null
```

### Serializing

[](#serializing)

You might run into a situation where you have to have all assigned properties available in an array or json. This package respects the `Arrayable` and `Jsonable` interfaces.

```
$product->props->details->toArray(); ['color' => 'red']
$product->props->details->toJson(); '{color: "red"}'
```

### Testing

[](#testing)

```
composer test
```

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

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

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [David Wesdijk](https://github.com/davidwesdijk)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance13

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~95 days

Total

7

Last Release

1547d ago

PHP version history (2 changes)v1.0PHP ^7.1

v1.0.4PHP ^7.1|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/1bed6286073d1cf970d9e17832905a8e3cba2634733cd697a9a1c82964b9dbfa?d=identicon)[davidwesdijk](/maintainers/davidwesdijk)

---

Top Contributors

[![davidwesdijk](https://avatars.githubusercontent.com/u/25476014?v=4)](https://github.com/davidwesdijk "davidwesdijk (14 commits)")

---

Tags

eaveav-modeleloquententity-attributeentity-attribute-valuelaravelphplaravel-polymorphic-eavpolymorphic-eaveav-model

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/davidwesdijk-laravel-polymorphic-eav/health.svg)

```
[![Health](https://phpackages.com/badges/davidwesdijk-laravel-polymorphic-eav/health.svg)](https://phpackages.com/packages/davidwesdijk-laravel-polymorphic-eav)
```

###  Alternatives

[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[cybercog/laravel-love

Make Laravel Eloquent models reactable with any type of emotions in a minutes!

1.2k302.7k1](/packages/cybercog-laravel-love)[cviebrock/eloquent-taggable

Easy ability to tag your Eloquent models in Laravel.

567694.8k3](/packages/cviebrock-eloquent-taggable)[clickbar/laravel-magellan

This package provides functionality for working with the postgis extension in Laravel.

423715.4k1](/packages/clickbar-laravel-magellan)[genealabs/laravel-pivot-events

This package introduces new eloquent events for sync(), attach(), detach() or updateExistingPivot() methods on BelongsToMany relation.

1404.9M8](/packages/genealabs-laravel-pivot-events)[reedware/laravel-relation-joins

Adds the ability to join on a relationship by name.

2121.2M13](/packages/reedware-laravel-relation-joins)

PHPackages © 2026

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