Files
nexusphp/app/Filament/Resources/System/AgentDenyResource.php

92 lines
3.1 KiB
PHP
Raw Normal View History

2022-06-27 01:39:01 +08:00
<?php
namespace App\Filament\Resources\System;
use App\Filament\Resources\System\AgentDenyResource\Pages;
use App\Filament\Resources\System\AgentDenyResource\RelationManagers;
use App\Models\AgentDeny;
use Filament\Forms;
2024-12-25 23:09:07 +08:00
use Filament\Forms\Form;
2022-06-27 01:39:01 +08:00
use Filament\Resources\Resource;
2024-12-25 23:09:07 +08:00
use Filament\Tables\Table;
2022-06-27 01:39:01 +08:00
use Filament\Tables;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
class AgentDenyResource extends Resource
{
protected static ?string $model = AgentDeny::class;
2024-12-25 23:09:07 +08:00
protected static ?string $navigationIcon = 'heroicon-o-no-symbol';
2022-06-27 01:39:01 +08:00
protected static ?string $navigationGroup = 'System';
2022-09-13 00:49:17 +08:00
protected static ?int $navigationSort = 5;
2022-07-02 15:08:23 +08:00
2024-12-25 23:09:07 +08:00
public static function getNavigationLabel(): string
2022-06-27 01:39:01 +08:00
{
return __('admin.sidebar.agent_denies');
}
2022-06-29 17:00:15 +08:00
public static function getBreadcrumb(): string
{
return self::getNavigationLabel();
}
2022-06-27 01:39:01 +08:00
public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Select::make('family_id')->label('Allow family')
->relationship('family', 'family')->required()->label(__('label.agent_allow.family')),
Forms\Components\TextInput::make('name')->required()->label(__('label.name')),
Forms\Components\TextInput::make('peer_id')->required()->label(__('label.agent_deny.peer_id')),
Forms\Components\TextInput::make('agent')->required()->label(__('label.agent_deny.agent')),
Forms\Components\Textarea::make('comment')->label(__('label.comment')),
2022-06-27 01:39:01 +08:00
]);
}
public static function table(Table $table): Table
{
return $table
->columns([
2022-07-02 16:36:44 +08:00
Tables\Columns\TextColumn::make('id')->sortable(),
Tables\Columns\TextColumn::make('family.family')->label(__('label.agent_allow.family')),
Tables\Columns\TextColumn::make('name')->searchable()->label(__('label.name')),
Tables\Columns\TextColumn::make('peer_id')->searchable()->label(__('label.agent_deny.peer_id')),
Tables\Columns\TextColumn::make('agent')->searchable()->label(__('label.agent_deny.agent')),
2022-06-27 01:39:01 +08:00
])
2022-07-02 16:36:44 +08:00
->defaultSort('id', 'desc')
2022-06-27 01:39:01 +08:00
->filters([
//
])
->actions([
Tables\Actions\EditAction::make(),
Tables\Actions\DeleteAction::make()->using(function ($record) {
$record->delete();
clear_agent_allow_deny_cache();
return redirect(self::getUrl());
})
2022-06-27 01:39:01 +08:00
])
->bulkActions([
Tables\Actions\DeleteBulkAction::make(),
]);
}
public static function getRelations(): array
{
return [
//
];
}
public static function getPages(): array
{
return [
'index' => Pages\ListAgentDenies::route('/'),
'create' => Pages\CreateAgentDeny::route('/create'),
'edit' => Pages\EditAgentDeny::route('/{record}/edit'),
];
}
}