Closed mepoohsta closed 6 years ago
Could you add a screenshot of your database state? The values related to this attribute.
I solved this issue by overriding some methods. Maybe, this? i forget.
public function pluck($value, $key = null)
{
$attribute = app('rinvex.attributes.attribute')->find($this->attribute->id);
//$items = $attribute->values(Attribute::getTypeModel($this->attribute->getAttribute('type')))->get();
$model = $this->entity;
$attribute = $this->attribute;
$attr_type = Attribute::getTypeModel($attribute->getAttribute('type'));
$instance = new $attr_type();
$items =$instance
->Leftjoin($model->getTable(), $model->getTable().'.id', '=', $instance->getTable().'.entity_id')
->where([
['entity_id', '=', $model->id],
['attribute_id', '=', $attribute->id],
])->get();
$items->entity = $model;
$items->attribute = $this->attribute;
$key = null;
$class = new static();
$class->attribute = $this->attribute;
$class->entity = $this->entity;
$class->items = Arr::pluck($items->items, $value, $key);
return $class;
}
Not sure right now. I would need to have the same state in the database to try to reproduce the issue.
It was not in the database, some method was returned not the ValueCollection() but the Collection().
@mepoohsta thank you for reaching out, and sorry for the delay!
Well, buddy there's no add
method in Laravel's Collections! AndValueCollection
actually inherits from it, so you just need to use push
like normal, make sure to READ THE WHOLE DOCUMENTATION as it's really mandatory to understand how this package works. And you can visit official Laravel Collections page too 🙂
P.S. If you're using this package for managing tags, it's not efficient and highly not recommended. You can use Rinvex Tags instead.
I don't know exactly what I need to do.
I want to add multiple values to attr. Trying this.
$model->tags->add(['Alexandria', 'Cairo'])
I added this code to my Model
`` /**
Get this