From df70dcc52167d1dc4644ffc2ceb94dbc0476b909 Mon Sep 17 00:00:00 2001 From: Attila Kerekes <439392+keriati@users.noreply.github.com> Date: Mon, 19 Dec 2022 13:40:38 +0000 Subject: [PATCH] feat: Add tags as classes to items (#1079) --- app/Item.php | 17 +++++++++++++++++ resources/views/item.blade.php | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/app/Item.php b/app/Item.php index 39f297a5..76a8be7c 100644 --- a/app/Item.php +++ b/app/Item.php @@ -153,6 +153,23 @@ class Item extends Model return $tagdetails; } + /** + * @return string + */ + public function getTagClass(): string + { + $tags = $this->tags(); + $slugs = []; + + foreach ($tags as $tag) { + if ($tag->url) { + $slugs[] = 'tag-'.$tag->url; + } + } + + return implode(' ', $slugs); + } + /** * @return BelongsToMany */ diff --git a/resources/views/item.blade.php b/resources/views/item.blade.php index 9686d17f..df4c7285 100644 --- a/resources/views/item.blade.php +++ b/resources/views/item.blade.php @@ -1,4 +1,4 @@ -
+
@if($app->icon)