migration script

# Conflicts:
#	app/Filament/Resources/Torrent/AnnounceLogResource.php
This commit is contained in:
NekoCH
2025-09-21 18:07:38 +08:00
parent f0b50e4826
commit 532f3bdb3f
131 changed files with 2177 additions and 1644 deletions

View File

@@ -2,6 +2,23 @@
namespace App\Filament\Resources\Section;
use Filament\Forms\Components\TextInput;
use Filament\Schemas\Schema;
use Filament\Forms\Components\CheckboxList;
use Filament\Forms\Components\Textarea;
use Filament\Schemas\Components\Section;
use Filament\Forms\Components\Toggle;
use Filament\Forms\Components\Repeater;
use Filament\Forms\Components\Select;
use Closure;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Columns\BooleanColumn;
use Filament\Actions\EditAction;
use Filament\Actions\DeleteAction;
use Filament\Actions\DeleteBulkAction;
use App\Filament\Resources\Section\SectionResource\Pages\ListSections;
use App\Filament\Resources\Section\SectionResource\Pages\CreateSection;
use App\Filament\Resources\Section\SectionResource\Pages\EditSection;
use App\Filament\Resources\Section\SectionResource\Pages;
use App\Filament\Resources\Section\SectionResource\RelationManagers;
use App\Http\Middleware\Locale;
@@ -9,7 +26,6 @@ use App\Models\Forum;
use App\Models\SearchBox;
use App\Models\TorrentCustomField;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables\Table;
use Filament\Tables;
@@ -27,9 +43,9 @@ class SectionResource extends Resource
protected static ?string $label = 'Section';
protected static ?string $navigationIcon = 'heroicon-o-view-columns';
protected static string | \BackedEnum | null $navigationIcon = 'heroicon-o-view-columns';
protected static ?string $navigationGroup = 'Section';
protected static string | \UnitEnum | null $navigationGroup = 'Section';
protected static ?int $navigationSort = 1;
@@ -47,18 +63,18 @@ class SectionResource extends Resource
{
$localeSchema = [];
foreach (Locale::$languageMaps as $lang => $locale) {
$localeSchema[] = Forms\Components\TextInput::make("$name.$lang")->required()->label($lang);
$localeSchema[] = TextInput::make("$name.$lang")->required()->label($lang);
}
return $localeSchema;
}
public static function form(Form $form): Form
public static function form(Schema $schema): Schema
{
$displayTextLocalSchema = self::buildLocalSchema('display_text');
$sectionNameLocalSchema = self::buildLocalSchema('section_name');
return $form
->schema([
Forms\Components\TextInput::make('name')
return $schema
->components([
TextInput::make('name')
->label(__('label.search_box.name'))
->rules(function ($record) {
return [
@@ -68,53 +84,53 @@ class SectionResource extends Resource
];
})
,
Forms\Components\TextInput::make('catsperrow')
TextInput::make('catsperrow')
->label(__('label.search_box.catsperrow'))
->helperText(__('label.search_box.catsperrow_help'))
->integer()
->required()
->default(8)
,
Forms\Components\TextInput::make('catpadding')
TextInput::make('catpadding')
->label(__('label.search_box.catpadding'))
->helperText(__('label.search_box.catpadding_help'))
->integer()
->required()
->default(3)
,
Forms\Components\CheckboxList::make('custom_fields')
CheckboxList::make('custom_fields')
->options(TorrentCustomField::getCheckboxOptions())
->label(__('label.search_box.custom_fields'))
->columns(4)
,
Forms\Components\TextInput::make('custom_fields_display_name')
TextInput::make('custom_fields_display_name')
->label(__('label.search_box.custom_fields_display_name'))
,
Forms\Components\Textarea::make('custom_fields_display')
Textarea::make('custom_fields_display')
->label(__('label.search_box.custom_fields_display'))
->helperText(__('label.search_box.custom_fields_display_help'))
,
Forms\Components\CheckboxList::make('other')
CheckboxList::make('other')
->options(SearchBox::listExtraText())
->columns(2)
->label(__('label.search_box.other'))
,
Forms\Components\Section::make(__('label.search_box.section_name'))
Section::make(__('label.search_box.section_name'))
->schema($sectionNameLocalSchema)
->columns(count($sectionNameLocalSchema))
,
Forms\Components\Toggle::make('showsubcat')->label(__('label.search_box.showsubcat'))->columnSpan(['sm' => 'full']),
Forms\Components\Section::make(__('label.search_box.showsubcat'))->schema([
Forms\Components\Repeater::make('extra.' . SearchBox::EXTRA_TAXONOMY_LABELS)
Toggle::make('showsubcat')->label(__('label.search_box.showsubcat'))->columnSpan(['sm' => 'full']),
Section::make(__('label.search_box.showsubcat'))->schema([
Repeater::make('extra.' . SearchBox::EXTRA_TAXONOMY_LABELS)
->schema([
Forms\Components\Select::make('torrent_field')->options(SearchBox::getSubCatOptions())->label(__('label.search_box.torrent_field')),
Forms\Components\Section::make(__('label.search_box.taxonomy_display_text'))->schema($displayTextLocalSchema)->columns(count($displayTextLocalSchema)),
Select::make('torrent_field')->options(SearchBox::getSubCatOptions())->label(__('label.search_box.torrent_field')),
Section::make(__('label.search_box.taxonomy_display_text'))->schema($displayTextLocalSchema)->columns(count($displayTextLocalSchema)),
])
->label(__('label.search_box.taxonomies'))
->rules([
function () {
return function (string $attribute, $value, \Closure $fail) {
return function (string $attribute, $value, Closure $fail) {
$fields = [];
foreach ($value as $item) {
if (!in_array($item['torrent_field'], $fields)) {
@@ -135,26 +151,26 @@ class SectionResource extends Resource
{
return $table
->columns([
Tables\Columns\TextColumn::make('id'),
Tables\Columns\TextColumn::make('name')->label(__('label.search_box.name')),
Tables\Columns\BooleanColumn::make('showsubcat')->label(__('label.search_box.showsubcat')),
Tables\Columns\BooleanColumn::make('showsource'),
Tables\Columns\BooleanColumn::make('showmedium'),
Tables\Columns\BooleanColumn::make('showcodec'),
Tables\Columns\BooleanColumn::make('showstandard'),
Tables\Columns\BooleanColumn::make('showprocessing'),
Tables\Columns\BooleanColumn::make('showteam'),
Tables\Columns\BooleanColumn::make('showaudiocodec'),
TextColumn::make('id'),
TextColumn::make('name')->label(__('label.search_box.name')),
BooleanColumn::make('showsubcat')->label(__('label.search_box.showsubcat')),
BooleanColumn::make('showsource'),
BooleanColumn::make('showmedium'),
BooleanColumn::make('showcodec'),
BooleanColumn::make('showstandard'),
BooleanColumn::make('showprocessing'),
BooleanColumn::make('showteam'),
BooleanColumn::make('showaudiocodec'),
])
->filters([
//
])
->actions([
Tables\Actions\EditAction::make(),
Tables\Actions\DeleteAction::make(),
->recordActions([
EditAction::make(),
DeleteAction::make(),
])
->bulkActions([
Tables\Actions\DeleteBulkAction::make(),
->toolbarActions([
DeleteBulkAction::make(),
]);
}
@@ -168,9 +184,9 @@ class SectionResource extends Resource
public static function getPages(): array
{
return [
'index' => Pages\ListSections::route('/'),
'create' => Pages\CreateSection::route('/create'),
'edit' => Pages\EditSection::route('/{record}/edit'),
'index' => ListSections::route('/'),
'create' => CreateSection::route('/create'),
'edit' => EditSection::route('/{record}/edit'),
];
}
}