Closed dhildreth closed 5 years ago
In my App\Attribute class which extends Rinvex\Attributes\Models\Attribute, I just added a scope to deal with it.
public function scopeInEntities($query, $entity_type)
{
return $query->whereHas('entities', function($query) use ($entity_type) {
$query->whereIn('entity_type', (array)$entity_type);
});
}
Is there a way to filter out the attributes that are tied to a specified entity?
To get a list of all attributes, we have:
$attributes = Attribute::all()
But, what if we just want attributes that belong to an entity, like this:
Similar to
$product->getEntityAttributes()
, but without needing to fetch an entity first. Any hints?