refactor: update server tag storage to individual columns and remove JSON tags migration
This commit is contained in:
@@ -23,12 +23,33 @@ class Server extends Model
|
||||
'user_set_icon',
|
||||
'user_set_icon_color',
|
||||
'user_set_icon_prefix',
|
||||
'tags',
|
||||
'tag1',
|
||||
'tag1color',
|
||||
'tag2',
|
||||
'tag2color',
|
||||
'tag3',
|
||||
'tag3color',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'tags' => 'array',
|
||||
];
|
||||
/**
|
||||
* Get tags as an array of objects
|
||||
*/
|
||||
public function getTagsAttribute(): array
|
||||
{
|
||||
$tags = [];
|
||||
|
||||
if (!empty($this->tag1)) {
|
||||
$tags[] = ['text' => $this->tag1, 'color' => $this->tag1color ?? '#3498db'];
|
||||
}
|
||||
if (!empty($this->tag2)) {
|
||||
$tags[] = ['text' => $this->tag2, 'color' => $this->tag2color ?? '#3498db'];
|
||||
}
|
||||
if (!empty($this->tag3)) {
|
||||
$tags[] = ['text' => $this->tag3, 'color' => $this->tag3color ?? '#3498db'];
|
||||
}
|
||||
|
||||
return $tags;
|
||||
}
|
||||
|
||||
public function node()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user