mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-14 20:40:49 +08:00
admin add claim
This commit is contained in:
@@ -4,22 +4,98 @@ namespace App\Filament\Resources\User\HitAndRunResource\Pages;
|
||||
|
||||
use App\Filament\Resources\User\HitAndRunResource;
|
||||
use App\Models\HitAndRun;
|
||||
use App\Repositories\HitAndRunRepository;
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
use Filament\Forms;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class ViewHitAndRun extends ViewRecord
|
||||
{
|
||||
protected static string $resource = HitAndRunResource::class;
|
||||
|
||||
protected function getFormSchema(): array
|
||||
protected static string $view = 'filament.detail-card';
|
||||
|
||||
private function getDetailCardData(): array
|
||||
{
|
||||
$data = [];
|
||||
$record = $this->record;
|
||||
$data[] = [
|
||||
'label' => 'ID',
|
||||
'value' => $record->id,
|
||||
];
|
||||
$data[] = [
|
||||
'label' => __('label.status'),
|
||||
'value' => $record->statusText,
|
||||
];
|
||||
$data[] = [
|
||||
'label' => __('label.username'),
|
||||
'value' => $record->user->username,
|
||||
];
|
||||
$data[] = [
|
||||
'label' => __('label.torrent.label'),
|
||||
'value' => $record->torrent->name,
|
||||
];
|
||||
$data[] = [
|
||||
'label' => __('label.uploaded'),
|
||||
'value' => $record->snatch->uploadedText,
|
||||
];
|
||||
$data[] = [
|
||||
'label' => __('label.downloaded'),
|
||||
'value' => $record->snatch->downloadedText,
|
||||
];
|
||||
$data[] = [
|
||||
'label' => __('label.ratio'),
|
||||
'value' => $record->snatch->shareRatio,
|
||||
];
|
||||
$data[] = [
|
||||
'label' => __('label.seed_time_required'),
|
||||
'value' => $record->seedTimeRequired,
|
||||
];
|
||||
$data[] = [
|
||||
'label' => __('label.inspect_time_left'),
|
||||
'value' => $record->inspectTimeLeft,
|
||||
];
|
||||
$data[] = [
|
||||
'label' => __('label.comment'),
|
||||
'value' => nl2br($record->comment),
|
||||
];
|
||||
$data[] = [
|
||||
'label' => __('label.created_at'),
|
||||
'value' => $record->created_at,
|
||||
];
|
||||
$data[] = [
|
||||
'label' => __('label.updated_at'),
|
||||
'value' => $record->updated_at,
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function getViewData(): array
|
||||
{
|
||||
return [
|
||||
Forms\Components\TextInput::make('id'),
|
||||
Forms\Components\TextInput::make('uid'),
|
||||
Forms\Components\Radio::make('status')->options(HitAndRun::listStatus(true))->inline(),
|
||||
Forms\Components\Textarea::make('comment'),
|
||||
Forms\Components\DateTimePicker::make('created_at'),
|
||||
'cardData' => $this->getDetailCardData(),
|
||||
];
|
||||
}
|
||||
|
||||
protected function getActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\Action::make('Pardon')
|
||||
->requiresConfirmation()
|
||||
->action(function () {
|
||||
$hitAndRunRep = new HitAndRunRepository();
|
||||
try {
|
||||
$hitAndRunRep->pardon($this->record->id, Auth::user());
|
||||
$this->notify('success', 'Success !');
|
||||
$this->record = $this->resolveRecord($this->record->id);
|
||||
} catch (\Exception $exception) {
|
||||
$this->notify('danger', $exception->getMessage());
|
||||
}
|
||||
})
|
||||
->label(__('admin.resources.hit_and_run.action_pardon')),
|
||||
|
||||
Actions\DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user