Skip to content
This repository has been archived by the owner on Feb 16, 2022. It is now read-only.

EAV values empty #30

Closed
psychonetic opened this issue Jan 10, 2018 · 3 comments
Closed

EAV values empty #30

psychonetic opened this issue Jan 10, 2018 · 3 comments

Comments

@psychonetic
Copy link
Contributor

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
Copy link
Member

Omranic commented Jan 11, 2018

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 17b0431

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 😉

@Omranic Omranic closed this as completed Jan 11, 2018
@psychonetic
Copy link
Contributor Author

psychonetic commented Jan 11, 2018

@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.

psychonetic added a commit to psychonetic/attributes that referenced this issue Jan 11, 2018
Omranic added a commit that referenced this issue Jan 11, 2018
@Omranic
Copy link
Member

Omranic commented Jan 11, 2018

My bad! 😅
PR merged 👌

Omranic added a commit that referenced this issue Feb 18, 2018
* release/v0.0.4: (56 commits)
  Update changelog
  Drop Laravel 5.5 support
  Update composer packages
  Update composer packages
  Apply fixes from StyleCI
  Check if attribute_entity database table exists before querying entity attributes
  Return eloquent collection always from getEntityAttributes method for compatibility
  Add force option to artisan commands
  Simplify IoC binding
  Update minimum required PHP version
  Add Laravel v5.6 support
  Sort attributes on retrieval
  Drop useless model contracts (models already swappable through IoC)
  Typehint method returns
  Typehint void method returns
  Fixed #30
  Fix entity custom primary id issue (fix #30, #26)
  Fix documentation code smaple
  Remove fillable relation rules
  Fix entities issue and tweak some features
  ...
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants