rinvex / laravel-attributes

⚠️ [ABANDONED] Rinvex Attributable is a robust, intelligent, and integrated Entity-Attribute-Value model (EAV) implementation for Laravel Eloquent, with powerful underlying for managing entity attributes implicitly as relations with ease. It utilizes the power of Laravel Eloquent, with smooth and seamless integration.
MIT License
433 stars 104 forks source link

How do you save multi-value attributes on an entity? #122

Closed jimrubenstein closed 2 years ago

jimrubenstein commented 4 years ago

The README shows that the proper way to add values to a multi-value attribute is using the ValueCollection@add method:

$Entity->my_attribute->add('foo');

However, when viewing the contents of the collection

dump($Entity->my_attribute);

The collection is empty.

Further, the object contained in my_attribute is not a ValueCollection, it's a standard Illuminate\Support\Collection.

Could you please share some insight or code examples on how multi-value attributes are intended to be used?

Thanks!

Omranic commented 2 years ago

I did a complete rewrite for the whole package and changed how collections work. In the new refactor, it actually uses normal relationships, and should be easy and straightforward like default Laravel relationships. Although, that refactor is incomplete.

I'm still not happy with the overall performance (I believe we can reduce number of executed queries), if you want to check it out, see https://github.com/rinvex/laravel-attributes/tree/refactor-to-native-laravel-relationships

Currently no plans to merge that rewrite, but hopefully sometime I can get it to a stable state, improve performance and release it. Any help with that branch would be much appreciated! 🙂