diff --git a/app/Filament/Resources/System/SectionResource.php b/app/Filament/Resources/System/SectionResource.php index c2038194..f2cdfdd4 100644 --- a/app/Filament/Resources/System/SectionResource.php +++ b/app/Filament/Resources/System/SectionResource.php @@ -51,11 +51,15 @@ class SectionResource extends Resource ->label(__('label.search_box.catsperrow')) ->helperText(__('label.search_box.catsperrow_help')) ->integer() + ->required() + ->default(8) , Forms\Components\TextInput::make('catpadding') ->label(__('label.search_box.catpadding')) ->helperText(__('label.search_box.catpadding_help')) ->integer() + ->required() + ->default(3) , Forms\Components\CheckboxList::make('custom_fields') ->options(TorrentCustomField::getCheckboxOptions()) @@ -115,7 +119,14 @@ class SectionResource extends Resource public static function getRelations(): array { return [ - // + RelationManagers\CategoriesRelationManager::class, + RelationManagers\TaxonomySourcesRelationManager::class, + RelationManagers\TaxonomyMediumRelationManager::class, + RelationManagers\TaxonomyCodecsRelationManager::class, + RelationManagers\TaxonomyAudioCodecsRelationManager::class, + RelationManagers\TaxonomyTeamsRelationManager::class, + RelationManagers\TaxonomyStandardsRelationManager::class, + RelationManagers\TaxonomyProcessingRelationManager::class, ]; } diff --git a/app/Filament/Resources/System/SectionResource/Pages/CreateSection.php b/app/Filament/Resources/System/SectionResource/Pages/CreateSection.php index 4c426dd8..f5051524 100644 --- a/app/Filament/Resources/System/SectionResource/Pages/CreateSection.php +++ b/app/Filament/Resources/System/SectionResource/Pages/CreateSection.php @@ -22,6 +22,11 @@ class CreateSection extends CreateRecord } } } - return array_filter($data); + return $data; + } + + protected function getRedirectUrl(): string + { + return static::$resource::getUrl('index'); } } diff --git a/app/Filament/Resources/System/SectionResource/Pages/EditSection.php b/app/Filament/Resources/System/SectionResource/Pages/EditSection.php index d8b9993e..db71eedd 100644 --- a/app/Filament/Resources/System/SectionResource/Pages/EditSection.php +++ b/app/Filament/Resources/System/SectionResource/Pages/EditSection.php @@ -29,6 +29,11 @@ class EditSection extends EditRecord } } } - return array_filter($data); + return $data; + } + + protected function getRedirectUrl(): ?string + { + return static::$resource::getUrl('index'); } } diff --git a/app/Filament/Resources/System/SectionResource/Pages/ListSections.php b/app/Filament/Resources/System/SectionResource/Pages/ListSections.php index 7c563ad4..28e0e981 100644 --- a/app/Filament/Resources/System/SectionResource/Pages/ListSections.php +++ b/app/Filament/Resources/System/SectionResource/Pages/ListSections.php @@ -17,4 +17,6 @@ class ListSections extends PageList Actions\CreateAction::make(), ]; } + + } diff --git a/app/Filament/Resources/System/SectionResource/RelationManagers/CategoriesRelationManager.php b/app/Filament/Resources/System/SectionResource/RelationManagers/CategoriesRelationManager.php new file mode 100644 index 00000000..e02ffcd0 --- /dev/null +++ b/app/Filament/Resources/System/SectionResource/RelationManagers/CategoriesRelationManager.php @@ -0,0 +1,69 @@ +schema([ + Forms\Components\TextInput::make('name')->required()->label(__('label.search_box.taxonomy.name')), + Forms\Components\TextInput::make('image') + ->rule('alpha_dash') + ->label(__('label.search_box.taxonomy.image')) + ->helperText(__('label.search_box.taxonomy.image_help')) + , + Forms\Components\TextInput::make('class_name') + ->label(__('label.search_box.taxonomy.class_name')) + ->helperText(__('label.search_box.taxonomy.class_name_help')) + , + Forms\Components\TextInput::make('sort_index') + ->default(0) + ->label(__('label.search_box.taxonomy.sort_index')) + ->helperText(__('label.search_box.taxonomy.sort_index_help')) + , + ]); + } + + public static function table(Table $table): Table + { + return $table + ->columns([ + Tables\Columns\TextColumn::make('id'), + Tables\Columns\TextColumn::make('name')->label(__('label.search_box.taxonomy.name')), + Tables\Columns\TextColumn::make('image')->label(__('label.search_box.taxonomy.image')), + Tables\Columns\TextColumn::make('class_name')->label(__('label.search_box.taxonomy.class_name')), + ]) + ->filters([ + // + ]) + ->headerActions([ + Tables\Actions\CreateAction::make(), + ]) + ->actions([ + Tables\Actions\EditAction::make(), + Tables\Actions\DeleteAction::make(), + ]) + ->bulkActions([ + Tables\Actions\DeleteBulkAction::make(), + ]); + } +} diff --git a/app/Filament/Resources/System/SectionResource/RelationManagers/TaxonomyAudioCodecsRelationManager.php b/app/Filament/Resources/System/SectionResource/RelationManagers/TaxonomyAudioCodecsRelationManager.php new file mode 100644 index 00000000..1f212ebe --- /dev/null +++ b/app/Filament/Resources/System/SectionResource/RelationManagers/TaxonomyAudioCodecsRelationManager.php @@ -0,0 +1,49 @@ +schema([ + Forms\Components\TextInput::make('name') + ->required() + ->maxLength(255), + ]); + } + + public static function table(Table $table): Table + { + return $table + ->columns([ + Tables\Columns\TextColumn::make('name'), + ]) + ->filters([ + // + ]) + ->headerActions([ + Tables\Actions\CreateAction::make(), + ]) + ->actions([ + Tables\Actions\EditAction::make(), + Tables\Actions\DeleteAction::make(), + ]) + ->bulkActions([ + Tables\Actions\DeleteBulkAction::make(), + ]); + } +} diff --git a/app/Filament/Resources/System/SectionResource/RelationManagers/TaxonomyCodecsRelationManager.php b/app/Filament/Resources/System/SectionResource/RelationManagers/TaxonomyCodecsRelationManager.php new file mode 100644 index 00000000..56eb9a25 --- /dev/null +++ b/app/Filament/Resources/System/SectionResource/RelationManagers/TaxonomyCodecsRelationManager.php @@ -0,0 +1,49 @@ +schema([ + Forms\Components\TextInput::make('name') + ->required() + ->maxLength(255), + ]); + } + + public static function table(Table $table): Table + { + return $table + ->columns([ + Tables\Columns\TextColumn::make('name'), + ]) + ->filters([ + // + ]) + ->headerActions([ + Tables\Actions\CreateAction::make(), + ]) + ->actions([ + Tables\Actions\EditAction::make(), + Tables\Actions\DeleteAction::make(), + ]) + ->bulkActions([ + Tables\Actions\DeleteBulkAction::make(), + ]); + } +} diff --git a/app/Filament/Resources/System/SectionResource/RelationManagers/TaxonomyMediumRelationManager.php b/app/Filament/Resources/System/SectionResource/RelationManagers/TaxonomyMediumRelationManager.php new file mode 100644 index 00000000..785abb5b --- /dev/null +++ b/app/Filament/Resources/System/SectionResource/RelationManagers/TaxonomyMediumRelationManager.php @@ -0,0 +1,49 @@ +schema([ + Forms\Components\TextInput::make('name') + ->required() + ->maxLength(255), + ]); + } + + public static function table(Table $table): Table + { + return $table + ->columns([ + Tables\Columns\TextColumn::make('name'), + ]) + ->filters([ + // + ]) + ->headerActions([ + Tables\Actions\CreateAction::make(), + ]) + ->actions([ + Tables\Actions\EditAction::make(), + Tables\Actions\DeleteAction::make(), + ]) + ->bulkActions([ + Tables\Actions\DeleteBulkAction::make(), + ]); + } +} diff --git a/app/Filament/Resources/System/SectionResource/RelationManagers/TaxonomyProcessingRelationManager.php b/app/Filament/Resources/System/SectionResource/RelationManagers/TaxonomyProcessingRelationManager.php new file mode 100644 index 00000000..bf318c9c --- /dev/null +++ b/app/Filament/Resources/System/SectionResource/RelationManagers/TaxonomyProcessingRelationManager.php @@ -0,0 +1,49 @@ +schema([ + Forms\Components\TextInput::make('name') + ->required() + ->maxLength(255), + ]); + } + + public static function table(Table $table): Table + { + return $table + ->columns([ + Tables\Columns\TextColumn::make('name'), + ]) + ->filters([ + // + ]) + ->headerActions([ + Tables\Actions\CreateAction::make(), + ]) + ->actions([ + Tables\Actions\EditAction::make(), + Tables\Actions\DeleteAction::make(), + ]) + ->bulkActions([ + Tables\Actions\DeleteBulkAction::make(), + ]); + } +} diff --git a/app/Filament/Resources/System/SectionResource/RelationManagers/TaxonomySourcesRelationManager.php b/app/Filament/Resources/System/SectionResource/RelationManagers/TaxonomySourcesRelationManager.php new file mode 100644 index 00000000..b8df0cf2 --- /dev/null +++ b/app/Filament/Resources/System/SectionResource/RelationManagers/TaxonomySourcesRelationManager.php @@ -0,0 +1,59 @@ +schema([ + Forms\Components\TextInput::make('name')->required(), + Forms\Components\TextInput::make('sort_index') + ->default(0) + ->label(__('label.search_box.taxonomy.sort_index')) + ->helperText(__('label.search_box.taxonomy.sort_index_help')) + , + ]); + } + + public static function table(Table $table): Table + { + return $table + ->columns([ + Tables\Columns\TextColumn::make('id'), + Tables\Columns\TextColumn::make('name')->label(__('label.search_box.taxonomy.name')), + ]) + ->filters([ + // + ]) + ->headerActions([ + Tables\Actions\CreateAction::make(), + ]) + ->actions([ + Tables\Actions\EditAction::make(), + Tables\Actions\DeleteAction::make(), + ]) + ->bulkActions([ + Tables\Actions\DeleteBulkAction::make(), + ]); + } +} diff --git a/app/Filament/Resources/System/SectionResource/RelationManagers/TaxonomyStandardsRelationManager.php b/app/Filament/Resources/System/SectionResource/RelationManagers/TaxonomyStandardsRelationManager.php new file mode 100644 index 00000000..fa4db83e --- /dev/null +++ b/app/Filament/Resources/System/SectionResource/RelationManagers/TaxonomyStandardsRelationManager.php @@ -0,0 +1,49 @@ +schema([ + Forms\Components\TextInput::make('name') + ->required() + ->maxLength(255), + ]); + } + + public static function table(Table $table): Table + { + return $table + ->columns([ + Tables\Columns\TextColumn::make('name'), + ]) + ->filters([ + // + ]) + ->headerActions([ + Tables\Actions\CreateAction::make(), + ]) + ->actions([ + Tables\Actions\EditAction::make(), + Tables\Actions\DeleteAction::make(), + ]) + ->bulkActions([ + Tables\Actions\DeleteBulkAction::make(), + ]); + } +} diff --git a/app/Filament/Resources/System/SectionResource/RelationManagers/TaxonomyTeamsRelationManager.php b/app/Filament/Resources/System/SectionResource/RelationManagers/TaxonomyTeamsRelationManager.php new file mode 100644 index 00000000..4872bc41 --- /dev/null +++ b/app/Filament/Resources/System/SectionResource/RelationManagers/TaxonomyTeamsRelationManager.php @@ -0,0 +1,49 @@ +schema([ + Forms\Components\TextInput::make('name') + ->required() + ->maxLength(255), + ]); + } + + public static function table(Table $table): Table + { + return $table + ->columns([ + Tables\Columns\TextColumn::make('name'), + ]) + ->filters([ + // + ]) + ->headerActions([ + Tables\Actions\CreateAction::make(), + ]) + ->actions([ + Tables\Actions\EditAction::make(), + Tables\Actions\DeleteAction::make(), + ]) + ->bulkActions([ + Tables\Actions\DeleteBulkAction::make(), + ]); + } +} diff --git a/app/Models/AudioCodec.php b/app/Models/AudioCodec.php index 22f1f90b..5f6f660f 100644 --- a/app/Models/AudioCodec.php +++ b/app/Models/AudioCodec.php @@ -7,6 +7,8 @@ class AudioCodec extends NexusModel { protected $table = 'audiocodecs'; + protected $fillable = ['name', 'sort_index']; + public static function getLabelName() { return nexus_trans('searchbox.sub_category_audio_codec_label'); diff --git a/app/Models/Codec.php b/app/Models/Codec.php index 2d0bbad5..265e4c5f 100644 --- a/app/Models/Codec.php +++ b/app/Models/Codec.php @@ -7,6 +7,8 @@ class Codec extends NexusModel { protected $table = 'codecs'; + protected $fillable = ['name', 'sort_index']; + public static function getLabelName() { return nexus_trans('searchbox.sub_category_codec_label'); diff --git a/app/Models/Media.php b/app/Models/Media.php index 3079c7bc..07a2df15 100644 --- a/app/Models/Media.php +++ b/app/Models/Media.php @@ -7,6 +7,8 @@ class Media extends NexusModel { protected $table = 'media'; + protected $fillable = ['name', 'sort_index']; + public static function getLabelName() { return nexus_trans('searchbox.sub_category_media_label'); diff --git a/app/Models/Processing.php b/app/Models/Processing.php index 7d48db49..5244c9ea 100644 --- a/app/Models/Processing.php +++ b/app/Models/Processing.php @@ -7,6 +7,8 @@ class Processing extends NexusModel { protected $table = 'processings'; + protected $fillable = ['name', 'sort_index']; + public static function getLabelName() { return nexus_trans('searchbox.sub_category_processing_label'); diff --git a/app/Models/SearchBox.php b/app/Models/SearchBox.php index 65aa2df8..9dcd45e8 100644 --- a/app/Models/SearchBox.php +++ b/app/Models/SearchBox.php @@ -45,6 +45,11 @@ class SearchBox extends NexusModel return $result; } + public static function getTaxonomyDisplayText($field) + { + + } + protected function customFields(): Attribute { return new Attribute( @@ -73,7 +78,7 @@ class SearchBox extends NexusModel return $this->hasMany(Source::class, 'mode'); } - public function taxonomy_media(): \Illuminate\Database\Eloquent\Relations\HasMany + public function taxonomy_medium(): \Illuminate\Database\Eloquent\Relations\HasMany { return $this->hasMany(Media::class, 'mode'); } diff --git a/app/Models/Source.php b/app/Models/Source.php index 5cd72c0a..ad6c3faf 100644 --- a/app/Models/Source.php +++ b/app/Models/Source.php @@ -5,6 +5,8 @@ namespace App\Models; class Source extends NexusModel { + protected $fillable = ['name', 'sort_index']; + public static function getLabelName() { return nexus_trans('searchbox.sub_category_source_label'); diff --git a/app/Models/Standard.php b/app/Models/Standard.php index 4403bd37..8ee6cb40 100644 --- a/app/Models/Standard.php +++ b/app/Models/Standard.php @@ -5,6 +5,8 @@ namespace App\Models; class Standard extends NexusModel { + protected $fillable = ['name', 'sort_index']; + public static function getLabelName() { return nexus_trans('searchbox.sub_category_standard_label'); diff --git a/app/Models/Team.php b/app/Models/Team.php index dfb3c859..7f475aee 100644 --- a/app/Models/Team.php +++ b/app/Models/Team.php @@ -5,6 +5,8 @@ namespace App\Models; class Team extends NexusModel { + protected $fillable = ['name', 'sort_index']; + public static function getLabelName() { return nexus_trans('searchbox.sub_category_team_label'); diff --git a/database/migrations/2022_09_06_030324_change_searchbox_field_extra_to_json.php b/database/migrations/2022_09_06_030324_change_searchbox_field_extra_to_json.php index b950aa15..dcfad32f 100644 --- a/database/migrations/2022_09_06_030324_change_searchbox_field_extra_to_json.php +++ b/database/migrations/2022_09_06_030324_change_searchbox_field_extra_to_json.php @@ -15,6 +15,12 @@ return new class extends Migration { Schema::table('searchbox', function (Blueprint $table) { $table->json('extra')->nullable()->change(); + $table->string('custom_fields_display_name')->nullable(true)->default('')->change(); + }); + + Schema::table('categories', function (Blueprint $table) { + $table->string('class_name')->nullable(true)->default('')->change(); + $table->string('image')->nullable(true)->default('')->change(); }); } diff --git a/resources/lang/zh_CN/label.php b/resources/lang/zh_CN/label.php index 2a0fe4d4..8b6c1f46 100644 --- a/resources/lang/zh_CN/label.php +++ b/resources/lang/zh_CN/label.php @@ -246,5 +246,15 @@ return [ 'custom_fields_display_name' => '自定义字段展示名称', 'custom_fields_display' => '自定义字段展示', 'custom_fields_display_help' => '使用特殊的标签代表字段的名称和值,如某字段其 Name 为 artist,则它的名称为:<%artist.label%>,它的值为:<%artist.value%>', + 'category' => '主分类', + 'taxonomy' => [ + 'name' => '名称', + 'sort_index' => '排序', + 'sort_index_help' => "递增排序,即'0'排在最前。", + 'class_name' => 'class属性值', + 'class_name_help' => "为图片指定class属性值。若无请留空。允许的字符: [a-z](小写),[0-9],[_],第一个字符必须是字母。", + 'image' => '图片文件名', + 'image_help' => '图片文件的名字。允许的字符:[a-z](小写),[0-9],[_./]。', + ], ], ];