mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-23 11:27:24 +08:00
migration script
# Conflicts: # app/Filament/Resources/Torrent/AnnounceLogResource.php
This commit is contained in:
@@ -2,6 +2,18 @@
|
||||
|
||||
namespace App\Filament\Resources\User;
|
||||
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
use Filament\Actions\ViewAction;
|
||||
use Filament\Actions\BulkAction;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use App\Filament\Resources\User\HitAndRunResource\Pages\ListHitAndRuns;
|
||||
use App\Filament\Resources\User\HitAndRunResource\Pages\ViewHitAndRun;
|
||||
use App\Filament\Resources\User\HitAndRunResource\Pages;
|
||||
use App\Filament\Resources\User\HitAndRunResource\RelationManagers;
|
||||
use App\Models\HitAndRun;
|
||||
@@ -9,7 +21,6 @@ use App\Models\User;
|
||||
use App\Repositories\HitAndRunRepository;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Infolists\Infolist;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables\Table;
|
||||
use Filament\Tables;
|
||||
@@ -26,9 +37,9 @@ class HitAndRunResource extends Resource
|
||||
{
|
||||
protected static ?string $model = HitAndRun::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-beaker';
|
||||
protected static string | \BackedEnum | null $navigationIcon = 'heroicon-o-beaker';
|
||||
|
||||
protected static ?string $navigationGroup = 'User';
|
||||
protected static string | \UnitEnum | null $navigationGroup = 'User';
|
||||
|
||||
protected static ?int $navigationSort = 3;
|
||||
|
||||
@@ -46,28 +57,28 @@ class HitAndRunResource extends Resource
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('id')->sortable(),
|
||||
Tables\Columns\TextColumn::make('uid')->searchable(),
|
||||
Tables\Columns\TextColumn::make('user.username')
|
||||
TextColumn::make('id')->sortable(),
|
||||
TextColumn::make('uid')->searchable(),
|
||||
TextColumn::make('user.username')
|
||||
->searchable()
|
||||
->label(__('label.username'))
|
||||
->formatStateUsing(fn ($record) => new HtmlString(get_username($record->uid, false, true, true, true)))
|
||||
,
|
||||
|
||||
Tables\Columns\TextColumn::make('torrent.name')->limit(30)->label(__('label.torrent.label')),
|
||||
Tables\Columns\TextColumn::make('snatch.uploadText')->label(__('label.uploaded')),
|
||||
Tables\Columns\TextColumn::make('snatch.downloadText')->label(__('label.downloaded')),
|
||||
Tables\Columns\TextColumn::make('snatch.shareRatio')->label(__('label.ratio')),
|
||||
Tables\Columns\TextColumn::make('seedTimeRequired')->label(__('label.seed_time_required')),
|
||||
Tables\Columns\TextColumn::make('inspectTimeLeft')->label(__('label.inspect_time_left')),
|
||||
Tables\Columns\TextColumn::make('statusText')->label(__('label.status')),
|
||||
Tables\Columns\TextColumn::make('created_at')->label(__('label.created_at')),
|
||||
TextColumn::make('torrent.name')->limit(30)->label(__('label.torrent.label')),
|
||||
TextColumn::make('snatch.uploadText')->label(__('label.uploaded')),
|
||||
TextColumn::make('snatch.downloadText')->label(__('label.downloaded')),
|
||||
TextColumn::make('snatch.shareRatio')->label(__('label.ratio')),
|
||||
TextColumn::make('seedTimeRequired')->label(__('label.seed_time_required')),
|
||||
TextColumn::make('inspectTimeLeft')->label(__('label.inspect_time_left')),
|
||||
TextColumn::make('statusText')->label(__('label.status')),
|
||||
TextColumn::make('created_at')->label(__('label.created_at')),
|
||||
])
|
||||
->defaultSort('id', 'desc')
|
||||
->filters([
|
||||
Tables\Filters\Filter::make('uid')
|
||||
->form([
|
||||
Forms\Components\TextInput::make('uid')
|
||||
Filter::make('uid')
|
||||
->schema([
|
||||
TextInput::make('uid')
|
||||
->label('UID')
|
||||
->placeholder('UID')
|
||||
,
|
||||
@@ -76,10 +87,10 @@ class HitAndRunResource extends Resource
|
||||
return $query->when($data['uid'], fn (Builder $query, $uid) => $query->where("uid", $uid));
|
||||
})
|
||||
,
|
||||
Tables\Filters\SelectFilter::make('status')->options(HitAndRun::listStatus(true))->label(__('label.status')),
|
||||
Tables\Filters\Filter::make('created_at_begin')
|
||||
->form([
|
||||
Forms\Components\DatePicker::make('created_at_begin')
|
||||
SelectFilter::make('status')->options(HitAndRun::listStatus(true))->label(__('label.status')),
|
||||
Filter::make('created_at_begin')
|
||||
->schema([
|
||||
DatePicker::make('created_at_begin')
|
||||
->maxDate(now())
|
||||
->label(__('label.created_at_begin'))
|
||||
,
|
||||
@@ -87,9 +98,9 @@ class HitAndRunResource extends Resource
|
||||
return $query->when($data['created_at_begin'], fn (Builder $query, $value) => $query->where("created_at", '>=', $value));
|
||||
})
|
||||
,
|
||||
Tables\Filters\Filter::make('created_at_end')
|
||||
->form([
|
||||
Forms\Components\DatePicker::make('created_at_end')
|
||||
Filter::make('created_at_end')
|
||||
->schema([
|
||||
DatePicker::make('created_at_end')
|
||||
->maxDate(now())
|
||||
->label(__('label.created_at_end'))
|
||||
,
|
||||
@@ -98,11 +109,11 @@ class HitAndRunResource extends Resource
|
||||
})
|
||||
,
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\ViewAction::make(),
|
||||
->recordActions([
|
||||
ViewAction::make(),
|
||||
])
|
||||
->groupedBulkActions([
|
||||
Tables\Actions\BulkAction::make('Pardon')->action(function (Collection $records) {
|
||||
BulkAction::make('Pardon')->action(function (Collection $records) {
|
||||
$idArr = $records->pluck('id')->toArray();
|
||||
$rep = new HitAndRunRepository();
|
||||
$rep->bulkPardon(['id' => $idArr], Auth::user());
|
||||
@@ -111,49 +122,49 @@ class HitAndRunResource extends Resource
|
||||
->label(__('admin.resources.hit_and_run.bulk_action_pardon'))
|
||||
->icon('heroicon-o-x-mark')
|
||||
,
|
||||
Tables\Actions\DeleteBulkAction::make('bulkDelete')
|
||||
DeleteBulkAction::make('bulkDelete')
|
||||
]);
|
||||
}
|
||||
|
||||
public static function infolist(Infolist $infolist): Infolist
|
||||
public static function infolist(Schema $schema): Schema
|
||||
{
|
||||
return $infolist
|
||||
->schema([
|
||||
Infolists\Components\TextEntry::make('id'),
|
||||
Infolists\Components\TextEntry::make('statusText')
|
||||
return $schema
|
||||
->components([
|
||||
TextEntry::make('id'),
|
||||
TextEntry::make('statusText')
|
||||
->label(__("label.status"))
|
||||
,
|
||||
Infolists\Components\TextEntry::make('uid')
|
||||
TextEntry::make('uid')
|
||||
->formatStateUsing(fn ($record) => username_for_admin($record->uid))
|
||||
->label(__("label.username"))
|
||||
,
|
||||
Infolists\Components\TextEntry::make('torrent_id')
|
||||
TextEntry::make('torrent_id')
|
||||
->formatStateUsing(fn ($record) => $record->torrent->name)
|
||||
->label(__("label.torrent.label"))
|
||||
,
|
||||
Infolists\Components\TextEntry::make('snatch.uploadedText')
|
||||
TextEntry::make('snatch.uploadedText')
|
||||
->label(__("label.uploaded"))
|
||||
,
|
||||
Infolists\Components\TextEntry::make('snatch.downloadedText')
|
||||
TextEntry::make('snatch.downloadedText')
|
||||
->label(__("label.downloaded"))
|
||||
,
|
||||
Infolists\Components\TextEntry::make('snatch.shareRatio')
|
||||
TextEntry::make('snatch.shareRatio')
|
||||
->label(__("label.ratio"))
|
||||
,
|
||||
Infolists\Components\TextEntry::make('seedTimeRequired')
|
||||
TextEntry::make('seedTimeRequired')
|
||||
->label(__("label.seed_time_required"))
|
||||
,
|
||||
Infolists\Components\TextEntry::make('inspectTimeLeft')
|
||||
TextEntry::make('inspectTimeLeft')
|
||||
->label(__("label.inspect_time_left"))
|
||||
,
|
||||
Infolists\Components\TextEntry::make('comment')
|
||||
TextEntry::make('comment')
|
||||
->formatStateUsing(fn ($record) => new HtmlString(nl2br($record->comment)))
|
||||
->label(__("label.comment"))
|
||||
,
|
||||
Infolists\Components\TextEntry::make('created_at')
|
||||
TextEntry::make('created_at')
|
||||
->label(__("label.created_at"))
|
||||
,
|
||||
Infolists\Components\TextEntry::make('updated_at')
|
||||
TextEntry::make('updated_at')
|
||||
->label(__("label.updated_at"))
|
||||
,
|
||||
])->columns(4);
|
||||
@@ -175,10 +186,10 @@ class HitAndRunResource extends Resource
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListHitAndRuns::route('/'),
|
||||
'index' => ListHitAndRuns::route('/'),
|
||||
// 'create' => Pages\CreateHitAndRun::route('/create'),
|
||||
// 'edit' => Pages\EditHitAndRun::route('/{record}/edit'),
|
||||
'view' => Pages\ViewHitAndRun::route('/{record}'),
|
||||
'view' => ViewHitAndRun::route('/{record}'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user