Fix issue with taggables
This commit is contained in:
@@ -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.
|
||||
*
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user