Skip to content

Commit 53e1677

Browse files
committed
fix seedBoxRecord
1 parent fd12d46 commit 53e1677

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

app/Filament/Resources/System/SeedBoxRecordResource.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public static function table(Table $table): Table
7474
Tables\Columns\TextColumn::make('operator')->label(__('label.seed_box_record.operator'))->searchable(),
7575
Tables\Columns\TextColumn::make('bandwidth')->label(__('label.seed_box_record.bandwidth')),
7676
Tables\Columns\TextColumn::make('asn')->label(__('label.seed_box_record.asn')),
77-
Tables\Columns\TextColumn::make('ip')
77+
Tables\Columns\TextColumn::make('ipRange')
7878
->label(__('label.seed_box_record.ip'))
7979
->searchable(true, function (Builder $query, $search) {
8080
try {
@@ -87,7 +87,7 @@ public static function table(Table $table): Table
8787
do_log("Invalid IP: $search, error: " . $exception->getMessage());
8888
}
8989
})
90-
->formatStateUsing(fn ($record) => $record->ip ?: sprintf('%s ~ %s', $record->ip_begin, $record->ip_end)),
90+
,
9191
Tables\Columns\TextColumn::make('comment')->label(__('label.comment'))->searchable(),
9292
Tables\Columns\IconColumn::make('is_allowed')->boolean()->label(__('label.seed_box_record.is_allowed')),
9393
Tables\Columns\BadgeColumn::make('status')
@@ -99,6 +99,7 @@ public static function table(Table $table): Table
9999
->formatStateUsing(fn ($record) => $record->statusText)
100100
->label(__('label.seed_box_record.status')),
101101
])
102+
->defaultSort('id', 'desc')
102103
->filters([
103104
Tables\Filters\Filter::make('id')
104105
->form([
@@ -148,7 +149,7 @@ public static function table(Table $table): Table
148149
try {
149150
$rep->updateStatus($record, $data['status'], $data['reason']);
150151
} catch (\Exception $exception) {
151-
Filament::notify('danger', class_basename($exception));
152+
send_admin_fail_notification(class_basename($exception));
152153
}
153154
})
154155
,

app/Filament/Resources/System/SeedBoxRecordResource/Pages/CreateSeedBoxRecord.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function create(bool $another = false): void
2222
$rep = new SeedBoxRepository();
2323
try {
2424
$this->record = $rep->store($data);
25-
$this->notify('success', $this->getCreatedNotificationTitle());
25+
send_admin_success_notification();
2626
if ($another) {
2727
// Ensure that the form record is anonymized so that relationships aren't loaded.
2828
$this->form->model($this->record::class);
@@ -34,7 +34,7 @@ public function create(bool $another = false): void
3434
}
3535
$this->redirect($this->getResource()::getUrl('index'));
3636
} catch (\Exception $exception) {
37-
$this->notify('danger', $exception->getMessage());
37+
send_admin_fail_notification($exception->getMessage());
3838
}
3939
}
4040
}

app/Models/SeedBoxRecord.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ protected function typeText(): Attribute
3737
);
3838
}
3939

40+
protected function ipRange(): Attribute
41+
{
42+
return new Attribute(
43+
get: fn($value, $attributes) => $attributes['ip'] ?: sprintf('%s ~ %s', $attributes['ip_begin'] ?? '', $attributes['ip_end'] ?? ''),
44+
);
45+
}
46+
4047
protected function statusText(): Attribute
4148
{
4249
return new Attribute(

0 commit comments

Comments
 (0)