feat: Add tags as classes to items (#1079)
This commit is contained in:
parent
9e6321e500
commit
df70dcc521
2 changed files with 18 additions and 1 deletions
17
app/Item.php
17
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
|
||||
*/
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<section class="item-container{{ $app->droppable }}" data-name="{{ $app->title }}" data-id="{{ $app->id }}">
|
||||
<section class="item-container{{ $app->droppable . ' ' . $app->getTagClass()}}" data-name="{{ $app->title }}" data-id="{{ $app->id }}">
|
||||
<div class="item" style="background-color: {{ $app->colour }}">
|
||||
<div class="app-icon-container">
|
||||
@if($app->icon)
|
||||
|
|
Loading…
Reference in a new issue