mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-24 12:07:23 +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('operator')->label(__('label.seed_box_record.operator'))->searchable(),
|
||||||
Tables\Columns\TextColumn::make('bandwidth')->label(__('label.seed_box_record.bandwidth')),
|
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('asn')->label(__('label.seed_box_record.asn')),
|
||||||
Tables\Columns\TextColumn::make('ip')
|
Tables\Columns\TextColumn::make('ipRange')
|
||||||
->label(__('label.seed_box_record.ip'))
|
->label(__('label.seed_box_record.ip'))
|
||||||
->searchable(true, function (Builder $query, $search) {
|
->searchable(true, function (Builder $query, $search) {
|
||||||
try {
|
try {
|
||||||
@@ -87,7 +87,7 @@ class SeedBoxRecordResource extends Resource
|
|||||||
do_log("Invalid IP: $search, error: " . $exception->getMessage());
|
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\TextColumn::make('comment')->label(__('label.comment'))->searchable(),
|
||||||
Tables\Columns\IconColumn::make('is_allowed')->boolean()->label(__('label.seed_box_record.is_allowed')),
|
Tables\Columns\IconColumn::make('is_allowed')->boolean()->label(__('label.seed_box_record.is_allowed')),
|
||||||
Tables\Columns\BadgeColumn::make('status')
|
Tables\Columns\BadgeColumn::make('status')
|
||||||
@@ -99,6 +99,7 @@ class SeedBoxRecordResource extends Resource
|
|||||||
->formatStateUsing(fn ($record) => $record->statusText)
|
->formatStateUsing(fn ($record) => $record->statusText)
|
||||||
->label(__('label.seed_box_record.status')),
|
->label(__('label.seed_box_record.status')),
|
||||||
])
|
])
|
||||||
|
->defaultSort('id', 'desc')
|
||||||
->filters([
|
->filters([
|
||||||
Tables\Filters\Filter::make('id')
|
Tables\Filters\Filter::make('id')
|
||||||
->form([
|
->form([
|
||||||
@@ -148,7 +149,7 @@ class SeedBoxRecordResource extends Resource
|
|||||||
try {
|
try {
|
||||||
$rep->updateStatus($record, $data['status'], $data['reason']);
|
$rep->updateStatus($record, $data['status'], $data['reason']);
|
||||||
} catch (\Exception $exception) {
|
} 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();
|
$rep = new SeedBoxRepository();
|
||||||
try {
|
try {
|
||||||
$this->record = $rep->store($data);
|
$this->record = $rep->store($data);
|
||||||
$this->notify('success', $this->getCreatedNotificationTitle());
|
send_admin_success_notification();
|
||||||
if ($another) {
|
if ($another) {
|
||||||
// Ensure that the form record is anonymized so that relationships aren't loaded.
|
// Ensure that the form record is anonymized so that relationships aren't loaded.
|
||||||
$this->form->model($this->record::class);
|
$this->form->model($this->record::class);
|
||||||
@@ -34,7 +34,7 @@ class CreateSeedBoxRecord extends CreateRecord
|
|||||||
}
|
}
|
||||||
$this->redirect($this->getResource()::getUrl('index'));
|
$this->redirect($this->getResource()::getUrl('index'));
|
||||||
} catch (\Exception $exception) {
|
} 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
|
protected function statusText(): Attribute
|
||||||
{
|
{
|
||||||
return new Attribute(
|
return new Attribute(
|
||||||
|
|||||||
Reference in New Issue
Block a user