Laravel Translatable
Closed this issue · 1 comments
ianfortier commented
Problem: We cannot use this package with Laravel Translatable
Error: Trait method getAttributeValue has not been applied, because there are collisions with other trait methods on App\\Product",
It would be nice to be able to use both in a model.
staudenmeir commented
You can combine the packages like this:
class Product extends Model
{
use HasJsonRelationships, HasTranslations {
HasJsonRelationships::getAttributeValue as getAttributeValueJson;
HasTranslations::getAttributeValue as getAttributeValueTranslations;
}
public function getAttributeValue($key)
{
if (! $this->isTranslatableAttribute($key)) {
return $this->getAttributeValueJson($key);
}
return $this->getAttributeValueTranslations($key);
}
}