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,12 +2,23 @@
namespace App\Filament\Resources\System;
use Filament\Schemas\Schema;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Radio;
use Filament\Forms\Components\Textarea;
use Filament\Tables\Columns\TextColumn;
use Filament\Actions\EditAction;
use Filament\Actions\DeleteAction;
use Filament\Actions\DeleteBulkAction;
use App\Filament\Resources\System\AgentAllowResource\RelationManagers\DeniesRelationManager;
use App\Filament\Resources\System\AgentAllowResource\Pages\ListAgentAllows;
use App\Filament\Resources\System\AgentAllowResource\Pages\CreateAgentAllow;
use App\Filament\Resources\System\AgentAllowResource\Pages\EditAgentAllow;
use App\Filament\OptionsTrait;
use App\Filament\Resources\System\AgentAllowResource\Pages;
use App\Filament\Resources\System\AgentAllowResource\RelationManagers;
use App\Models\AgentAllow;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables\Table;
use Filament\Tables;
@@ -20,9 +31,9 @@ class AgentAllowResource extends Resource
protected static ?string $model = AgentAllow::class;
protected static ?string $navigationIcon = 'heroicon-o-check';
protected static string | \BackedEnum | null $navigationIcon = 'heroicon-o-check';
protected static ?string $navigationGroup = 'System';
protected static string | \UnitEnum | null $navigationGroup = 'System';
protected static ?int $navigationSort = 4;
@@ -37,24 +48,24 @@ class AgentAllowResource extends Resource
}
public static function form(Form $form): Form
public static function form(Schema $schema): Schema
{
return $form
->schema([
Forms\Components\TextInput::make('family')->required()->label(__('label.agent_allow.family')),
Forms\Components\TextInput::make('start_name')->required()->label(__('label.agent_allow.start_name')),
Forms\Components\TextInput::make('peer_id_start')->required()->label(__('label.agent_allow.peer_id_start')),
Forms\Components\TextInput::make('peer_id_pattern')->required()->label(__('label.agent_allow.peer_id_pattern')),
Forms\Components\Radio::make('peer_id_matchtype')->options(self::$matchTypes)->required()->label(__('label.agent_allow.peer_id_matchtype')),
Forms\Components\TextInput::make('peer_id_match_num')->integer()->required()->label(__('label.agent_allow.peer_id_match_num')),
Forms\Components\TextInput::make('agent_start')->required()->label(__('label.agent_allow.agent_start')),
Forms\Components\TextInput::make('agent_pattern')->required()->label(__('label.agent_allow.agent_pattern')),
Forms\Components\Radio::make('agent_matchtype')->options(self::$matchTypes)->required()->label(__('label.agent_allow.agent_matchtype')),
Forms\Components\TextInput::make('agent_match_num')->required()->label(__('label.agent_allow.agent_match_num')),
Forms\Components\Radio::make('exception')->options(self::$yesOrNo)->required()->label(__('label.agent_allow.exception')),
Forms\Components\Radio::make('allowhttps')->options(self::$yesOrNo)->required()->label(__('label.agent_allow.allowhttps')),
return $schema
->components([
TextInput::make('family')->required()->label(__('label.agent_allow.family')),
TextInput::make('start_name')->required()->label(__('label.agent_allow.start_name')),
TextInput::make('peer_id_start')->required()->label(__('label.agent_allow.peer_id_start')),
TextInput::make('peer_id_pattern')->required()->label(__('label.agent_allow.peer_id_pattern')),
Radio::make('peer_id_matchtype')->options(self::$matchTypes)->required()->label(__('label.agent_allow.peer_id_matchtype')),
TextInput::make('peer_id_match_num')->integer()->required()->label(__('label.agent_allow.peer_id_match_num')),
TextInput::make('agent_start')->required()->label(__('label.agent_allow.agent_start')),
TextInput::make('agent_pattern')->required()->label(__('label.agent_allow.agent_pattern')),
Radio::make('agent_matchtype')->options(self::$matchTypes)->required()->label(__('label.agent_allow.agent_matchtype')),
TextInput::make('agent_match_num')->required()->label(__('label.agent_allow.agent_match_num')),
Radio::make('exception')->options(self::$yesOrNo)->required()->label(__('label.agent_allow.exception')),
Radio::make('allowhttps')->options(self::$yesOrNo)->required()->label(__('label.agent_allow.allowhttps')),
Forms\Components\Textarea::make('comment')->label(__('label.comment')),
Textarea::make('comment')->label(__('label.comment')),
]);
}
@@ -62,42 +73,42 @@ class AgentAllowResource extends Resource
{
return $table
->columns([
Tables\Columns\TextColumn::make('id')->sortable(),
Tables\Columns\TextColumn::make('family')->searchable()->label(__('label.agent_allow.family')),
Tables\Columns\TextColumn::make('start_name')->searchable()->label(__('label.agent_allow.start_name')),
Tables\Columns\TextColumn::make('peer_id_start')->label(__('label.agent_allow.peer_id_start')),
Tables\Columns\TextColumn::make('agent_start')->label(__('label.agent_allow.agent_start')),
TextColumn::make('id')->sortable(),
TextColumn::make('family')->searchable()->label(__('label.agent_allow.family')),
TextColumn::make('start_name')->searchable()->label(__('label.agent_allow.start_name')),
TextColumn::make('peer_id_start')->label(__('label.agent_allow.peer_id_start')),
TextColumn::make('agent_start')->label(__('label.agent_allow.agent_start')),
])
->defaultSort('id', 'desc')
->filters([
//
])
->actions([
Tables\Actions\EditAction::make(),
Tables\Actions\DeleteAction::make()->using(function ($record) {
->recordActions([
EditAction::make(),
DeleteAction::make()->using(function ($record) {
$record->delete();
clear_agent_allow_deny_cache();
return redirect(self::getUrl());
})
])
->bulkActions([
Tables\Actions\DeleteBulkAction::make(),
->toolbarActions([
DeleteBulkAction::make(),
]);
}
public static function getRelations(): array
{
return [
RelationManagers\DeniesRelationManager::class,
DeniesRelationManager::class,
];
}
public static function getPages(): array
{
return [
'index' => Pages\ListAgentAllows::route('/'),
'create' => Pages\CreateAgentAllow::route('/create'),
'edit' => Pages\EditAgentAllow::route('/{record}/edit'),
'index' => ListAgentAllows::route('/'),
'create' => CreateAgentAllow::route('/create'),
'edit' => EditAgentAllow::route('/{record}/edit'),
];
}
}