diff --git a/src/Scopes/EntityAttributeValueScopes.php b/src/Scopes/EntityAttributeValueScopes.php new file mode 100644 index 0000000..75622e1 --- /dev/null +++ b/src/Scopes/EntityAttributeValueScopes.php @@ -0,0 +1,32 @@ +id : $attribute; + + return $query->whereHas(static::$relationName, function (Builder $query) use ($attributeId) { + $query->where('entity_attribute_id', $attributeId); + }); + } +} diff --git a/src/Traits/HasEntityAttributeValues.php b/src/Traits/HasEntityAttributeValues.php index c4f8db8..8c4a12e 100644 --- a/src/Traits/HasEntityAttributeValues.php +++ b/src/Traits/HasEntityAttributeValues.php @@ -4,9 +4,16 @@ use DavidWesdijk\LaravelPolymorphicEav\EntityAttributeValue; use DavidWesdijk\LaravelPolymorphicEav\Resolvers\GroupResolver; +use DavidWesdijk\LaravelPolymorphicEav\Scopes\EntityAttributeValueScopes; +/** + * Trait HasEntityAttributeValues + * @package DavidWesdijk\LaravelPolymorphicEav\Traits + */ trait HasEntityAttributeValues { + use EntityAttributeValueScopes; + /** * @var string */