Closed joaopmmartins closed 5 years ago
@joaopmmartins
At this time this is not possible. findByCode
is a static method on Eav\Attribute
.
You can make use of https://laravel.com/docs/5.7/eloquent-relationships#lazy-eager-loading
$statusAttr = Eav\Attribute::findByCode('size', 'product');
$statusAttr->load('optionValues');
// You must use this to access the options.
$statusAttr->options();
I am planning to convert this a scoped query.
@joaopmmartins
I have updated the doc, sorry for the wrong update in the doc, the right way is to use as mention in the comments
When I run the code:
$statusAttr = Eav\Attribute::with('optionValues')->findByCode('size', 'product');
I get the following error:
BadMethodCallException Call to undefined method Illuminate\Database\Eloquent\Builder::findByCode()