新增 UsdtC2C Resource 与页面
This commit is contained in:
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Resources\TgCommResource\Pages;
|
||||
use App\Filament\Resources\TgCommResource\RelationManagers;
|
||||
use App\Models\TgComm;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
// use Filament\Forms\Components\TextInput;
|
||||
// use Filament\Forms\Components\Toggle;
|
||||
use Filament\Forms\Components\{TextInput, Toggle, Section, Grid};
|
||||
|
||||
class TgCommResource extends Resource
|
||||
{
|
||||
protected static ?string $model = TgComm::class;
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
protected static ?string $navigationLabel = '指令列表'; // 左侧菜单文字
|
||||
protected static ?int $navigationSort = 10;
|
||||
protected static ?string $pluralModelLabel = '指令列表'; // 页面标题
|
||||
protected static ?string $modelLabel = '指令';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form->schema([
|
||||
|
||||
Section::make('基本信息')->schema([
|
||||
Grid::make(2)->schema([
|
||||
TextInput::make('command')
|
||||
->label('指令内容')
|
||||
->required(),
|
||||
|
||||
TextInput::make('description')
|
||||
->label('指令用途'),
|
||||
]),
|
||||
|
||||
TextInput::make('action')
|
||||
->label('使用说明')
|
||||
->columnSpanFull(),
|
||||
]),
|
||||
|
||||
Section::make('设置')->schema([
|
||||
Grid::make(3)->schema([
|
||||
Toggle::make('display')->label('显示在指令列表'),
|
||||
Toggle::make('manager')->label('管理员权限'),
|
||||
Toggle::make('valid')->label('启用'),
|
||||
]),
|
||||
]),
|
||||
|
||||
]);
|
||||
}
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('id')->label('ID'),
|
||||
TextColumn::make('command')->label('指令内容'),
|
||||
TextColumn::make('instructions')->label('指令说明'),
|
||||
TextColumn::make('memo')->label('使用说明'),
|
||||
TextColumn::make('dis_play')->label('列表显示'),
|
||||
TextColumn::make('manager')->label('管理权限'),
|
||||
TextColumn::make('valid')->label('停/启用'),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\EditAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListTgComms::route('/'),
|
||||
'create' => Pages\CreateTgComm::route('/create'),
|
||||
'edit' => Pages\EditTgComm::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user