Fix issue with taggables

This commit is contained in:
James Brooks
2018-05-11 17:57:29 +01:00
parent db8874c5ad
commit 47f0077928
2 changed files with 3 additions and 18 deletions

View File

@@ -64,7 +64,6 @@ class Component extends Model implements HasPresenter
'name',
'description',
'status',
'tags',
'link',
'order',
'group_id',
@@ -147,11 +146,11 @@ class Component extends Model implements HasPresenter
/**
* Get the tags relation.
*
* @return \Illuminate\Database\Eloquent\Relations\MorphToMany
* @return \Illuminate\Database\Eloquent\Relations\MorphMany
*/
public function tags()
{
return $this->morphToMany(Taggable::class, 'taggable');
return $this->morphMany(Taggable::class, 'taggable');
}
/**
@@ -250,20 +249,6 @@ class Component extends Model implements HasPresenter
->groupBy('group_id');
}
/**
* Returns all of the tags on this component.
*
* @return string
*/
public function getTagsListAttribute()
{
$tags = $this->tags->map(function ($tag) {
return $tag->name;
});
return implode(', ', $tags->toArray());
}
/**
* Get the presenter class.
*

View File

@@ -53,7 +53,7 @@ class ComponentPresenter extends BasePresenter implements Arrayable
*/
public function tags()
{
return $this->wrappedObject->tags->pluck('name', 'slug');
return $this->wrappedObject->tags->pluck('tag.name', 'tag.slug');
}
/**