From 1ff92df6d2ce4c55eba70248a4c9d0c644784dea Mon Sep 17 00:00:00 2001 From: xiaomlove Date: Wed, 11 Jan 2023 05:05:18 +0800 Subject: [PATCH] tag add description --- .../Resources/Torrent/TagResource.php | 1 + app/Models/Tag.php | 2 +- app/Repositories/TagRepository.php | 4 +-- ...1_044915_add_description_to_tags_table.php | 32 +++++++++++++++++++ include/constants.php | 2 +- include/functions.php | 5 ++- 6 files changed, 41 insertions(+), 5 deletions(-) create mode 100644 database/migrations/2023_01_11_044915_add_description_to_tags_table.php diff --git a/app/Filament/Resources/Torrent/TagResource.php b/app/Filament/Resources/Torrent/TagResource.php index cd30070e..baa62abf 100644 --- a/app/Filament/Resources/Torrent/TagResource.php +++ b/app/Filament/Resources/Torrent/TagResource.php @@ -51,6 +51,7 @@ class TagResource extends Resource ->label(__('label.search_box.taxonomy.mode')) ->helperText(__('label.search_box.taxonomy.mode_help')) , + Forms\Components\Textarea::make('description')->label(__('label.description')), ]); } diff --git a/app/Models/Tag.php b/app/Models/Tag.php index 8bb0e379..ca0afe19 100644 --- a/app/Models/Tag.php +++ b/app/Models/Tag.php @@ -9,7 +9,7 @@ class Tag extends NexusModel protected $fillable = [ 'id', 'name', 'color', 'priority', 'created_at', 'updated_at', 'font_size', 'font_color', 'padding', 'margin', 'border_radius', - 'mode', + 'mode', 'description' ]; const DEFAULTS = [ diff --git a/app/Repositories/TagRepository.php b/app/Repositories/TagRepository.php index 4af421ee..81feb9f1 100644 --- a/app/Repositories/TagRepository.php +++ b/app/Repositories/TagRepository.php @@ -75,8 +75,8 @@ class TagRepository extends BaseRepository $tagId = $value->id; if ($value) { $item = sprintf( - "%s", - $value->color, $value->font_color, $value->border_radius, $value->font_size, $value->margin, $value->padding, $value->name + "%s", + $value->color, $value->font_color, $value->border_radius, $value->font_size, $value->margin, $value->padding, $value->description, $value->name ); if ($withFilterLink) { $html .= sprintf('%s', $tagId, $item); diff --git a/database/migrations/2023_01_11_044915_add_description_to_tags_table.php b/database/migrations/2023_01_11_044915_add_description_to_tags_table.php new file mode 100644 index 00000000..0e3f46f9 --- /dev/null +++ b/database/migrations/2023_01_11_044915_add_description_to_tags_table.php @@ -0,0 +1,32 @@ +text('description')->after('font_color')->nullable(true); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('tags', function (Blueprint $table) { + $table->dropColumn('description'); + }); + } +}; diff --git a/include/constants.php b/include/constants.php index 542f1ede..65af13d3 100644 --- a/include/constants.php +++ b/include/constants.php @@ -1,6 +1,6 @@ %s', $torrent->id, $torrent->name, Str::limit($torrent->name, 40)