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 can I list out all of my attributes and values #161

Closed thecyrilcril closed 2 years ago

thecyrilcril commented 3 years ago

I would like to list out all of my attributes and values so I can use them for filtering the entity. how do I achieve that?

cord commented 2 years ago

here is my solution (requires some adoption):



        // get type of attribute through the entity
        $attribute = app('rinvex.attributes.attribute')::whereSlug($attributeSlug)
            ->whereHas('entities', function ($query) use ($class) {
                $query->where('entity_type', '=',  $class);
            })
            ->first();

        $attributeClass = \Rinvex\Attributes\Models\Attribute::getTypeModel($attribute->type);
        $distinctValues = $attributeClass::select('content')->whereAttributeId($attribute->id)->distinct()->get()->pluck('content')->toArray();
Omranic commented 2 years ago

Seems to be solved, thank you @cord for your help.