mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-21 18:37:31 +08:00
fix seedBoxRecord
This commit is contained in:
@@ -74,7 +74,7 @@ class SeedBoxRecordResource extends Resource
|
||||
Tables\Columns\TextColumn::make('operator')->label(__('label.seed_box_record.operator'))->searchable(),
|
||||
Tables\Columns\TextColumn::make('bandwidth')->label(__('label.seed_box_record.bandwidth')),
|
||||
Tables\Columns\TextColumn::make('asn')->label(__('label.seed_box_record.asn')),
|
||||
Tables\Columns\TextColumn::make('ip')
|
||||
Tables\Columns\TextColumn::make('ipRange')
|
||||
->label(__('label.seed_box_record.ip'))
|
||||
->searchable(true, function (Builder $query, $search) {
|
||||
try {
|
||||
@@ -87,7 +87,7 @@ class SeedBoxRecordResource extends Resource
|
||||
do_log("Invalid IP: $search, error: " . $exception->getMessage());
|
||||
}
|
||||
})
|
||||
->formatStateUsing(fn ($record) => $record->ip ?: sprintf('%s ~ %s', $record->ip_begin, $record->ip_end)),
|
||||
,
|
||||
Tables\Columns\TextColumn::make('comment')->label(__('label.comment'))->searchable(),
|
||||
Tables\Columns\IconColumn::make('is_allowed')->boolean()->label(__('label.seed_box_record.is_allowed')),
|
||||
Tables\Columns\BadgeColumn::make('status')
|
||||
@@ -99,6 +99,7 @@ class SeedBoxRecordResource extends Resource
|
||||
->formatStateUsing(fn ($record) => $record->statusText)
|
||||
->label(__('label.seed_box_record.status')),
|
||||
])
|
||||
->defaultSort('id', 'desc')
|
||||
->filters([
|
||||
Tables\Filters\Filter::make('id')
|
||||
->form([
|
||||
@@ -148,7 +149,7 @@ class SeedBoxRecordResource extends Resource
|
||||
try {
|
||||
$rep->updateStatus($record, $data['status'], $data['reason']);
|
||||
} catch (\Exception $exception) {
|
||||
Filament::notify('danger', class_basename($exception));
|
||||
send_admin_fail_notification(class_basename($exception));
|
||||
}
|
||||
})
|
||||
,
|
||||
|
||||
@@ -22,7 +22,7 @@ class CreateSeedBoxRecord extends CreateRecord
|
||||
$rep = new SeedBoxRepository();
|
||||
try {
|
||||
$this->record = $rep->store($data);
|
||||
$this->notify('success', $this->getCreatedNotificationTitle());
|
||||
send_admin_success_notification();
|
||||
if ($another) {
|
||||
// Ensure that the form record is anonymized so that relationships aren't loaded.
|
||||
$this->form->model($this->record::class);
|
||||
@@ -34,7 +34,7 @@ class CreateSeedBoxRecord extends CreateRecord
|
||||
}
|
||||
$this->redirect($this->getResource()::getUrl('index'));
|
||||
} catch (\Exception $exception) {
|
||||
$this->notify('danger', $exception->getMessage());
|
||||
send_admin_fail_notification($exception->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,13 @@ class SeedBoxRecord extends NexusModel
|
||||
);
|
||||
}
|
||||
|
||||
protected function ipRange(): Attribute
|
||||
{
|
||||
return new Attribute(
|
||||
get: fn($value, $attributes) => $attributes['ip'] ?: sprintf('%s ~ %s', $attributes['ip_begin'] ?? '', $attributes['ip_end'] ?? ''),
|
||||
);
|
||||
}
|
||||
|
||||
protected function statusText(): Attribute
|
||||
{
|
||||
return new Attribute(
|
||||
|
||||
Reference in New Issue
Block a user