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

EAV values empty #30

Closed psychonetic closed 6 years ago

psychonetic commented 6 years ago

Soo @Omranic.

I followed your steps and created a new laravel project and I am still unable to get the data. Here is the link to the repo: https://github.com/psychonetic/laravel-attributes

Just migrate the database, run php artisan serve and hit the following url: localhost:8000/api/articles.

A size attribute is created, after an article and also applied the size to the article and finally I try to get the result. But as already discussed in #26 the size is always null.

Best regards,

Marco

Omranic commented 6 years ago

OMG! I created a new project and as always it was working fine, but it never did with yours, it drove me crazy and consumed few hours until I figured you're using custom primary key for your model which I didn't notice before, and that made sense then!! Thank god it's now solved with one tiny simple change 17b043145a518460d8cd4acf64320ba86d8ac251

composer update and you'll be good to go. Thanks @psychonetic for your persistence 😅 This was a tricky one. Happy to help if you need further assistance 😉

psychonetic commented 6 years ago

@Omranic Sorry, but I need to bother you again and the issue is still not fixed. The method getKey returns the value of the primary key and not the name of the primaryKey.

/**
     * Get the value of the model's primary key.
     *
     * @return mixed
     */
    public function getKey()
    {
        return $this->getAttribute($this->getKeyName());
    }

You should change getKey to getKeyName. That should to the trick. Otherwise an exception is thrown, because some of your methods require a string, but if you use getKey() it returns certainly an int.

@Omranic

I added a pull request.

Omranic commented 6 years ago

My bad! 😅 PR merged 👌