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

102 lines
3.4 KiB
PHP
Raw Normal View History

2022-06-27 01:39:01 +08:00
<?php
namespace App\Filament\Resources\System;
use Filament\Schemas\Schema;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Textarea;
use Filament\Tables\Columns\TextColumn;
use Filament\Actions\EditAction;
use Filament\Actions\DeleteAction;
use Filament\Actions\DeleteBulkAction;
use App\Filament\Resources\System\AgentDenyResource\Pages\ListAgentDenies;
use App\Filament\Resources\System\AgentDenyResource\Pages\CreateAgentDeny;
use App\Filament\Resources\System\AgentDenyResource\Pages\EditAgentDeny;
2022-06-27 01:39:01 +08:00
use App\Filament\Resources\System\AgentDenyResource\Pages;
use App\Filament\Resources\System\AgentDenyResource\RelationManagers;
use App\Models\AgentDeny;
use Filament\Forms;
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;
protected static string | \BackedEnum | null $navigationIcon = 'heroicon-o-no-symbol';
2022-06-27 01:39:01 +08:00
protected static string | \UnitEnum | null $navigationGroup = 'System';
2022-06-27 01:39:01 +08:00
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();
}
public static function form(Schema $schema): Schema
2022-06-27 01:39:01 +08:00
{
return $schema
->components([
Select::make('family_id')->label('Allow family')
->relationship('family', 'family')->required()->label(__('label.agent_allow.family')),
TextInput::make('name')->required()->label(__('label.name')),
TextInput::make('peer_id')->required()->label(__('label.agent_deny.peer_id')),
TextInput::make('agent')->required()->label(__('label.agent_deny.agent')),
Textarea::make('comment')->label(__('label.comment')),
2022-06-27 01:39:01 +08:00
]);
}
public static function table(Table $table): Table
{
return $table
->columns([
TextColumn::make('id')->sortable(),
TextColumn::make('family.family')->label(__('label.agent_allow.family')),
TextColumn::make('name')->searchable()->label(__('label.name')),
TextColumn::make('peer_id')->searchable()->label(__('label.agent_deny.peer_id')),
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([
//
])
->recordActions([
EditAction::make(),
DeleteAction::make()->using(function ($record) {
$record->delete();
clear_agent_allow_deny_cache();
return redirect(self::getUrl());
})
2022-06-27 01:39:01 +08:00
])
->toolbarActions([
DeleteBulkAction::make(),
2022-06-27 01:39:01 +08:00
]);
}
public static function getRelations(): array
{
return [
//
];
}
public static function getPages(): array
{
return [
'index' => ListAgentDenies::route('/'),
'create' => CreateAgentDeny::route('/create'),
'edit' => EditAgentDeny::route('/{record}/edit'),
2022-06-27 01:39:01 +08:00
];
}
}