From 47f00779285376cbdedef20d52516a38e5028f68 Mon Sep 17 00:00:00 2001 From: James Brooks Date: Fri, 11 May 2018 17:57:29 +0100 Subject: [PATCH] Fix issue with taggables --- app/Models/Component.php | 19 ++----------------- app/Presenters/ComponentPresenter.php | 2 +- 2 files changed, 3 insertions(+), 18 deletions(-) diff --git a/app/Models/Component.php b/app/Models/Component.php index 8a28f848..37a20638 100644 --- a/app/Models/Component.php +++ b/app/Models/Component.php @@ -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. * diff --git a/app/Presenters/ComponentPresenter.php b/app/Presenters/ComponentPresenter.php index 07a2458e..30bb2239 100644 --- a/app/Presenters/ComponentPresenter.php +++ b/app/Presenters/ComponentPresenter.php @@ -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'); } /**