|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Cachet\Filament\Resources\ComponentResource\RelationManagers; |
| 4 | + |
| 5 | +use Cachet\Enums\ComponentStatusEnum; |
| 6 | +use Filament\Forms; |
| 7 | +use Filament\Forms\Form; |
| 8 | +use Filament\Resources\RelationManagers\RelationManager; |
| 9 | +use Filament\Tables; |
| 10 | +use Filament\Tables\Table; |
| 11 | + |
| 12 | +class ComponentsRelationManager extends RelationManager |
| 13 | +{ |
| 14 | + protected static string $relationship = 'components'; |
| 15 | + |
| 16 | + public function form(Form $form): Form |
| 17 | + { |
| 18 | + return $form |
| 19 | + ->schema([ |
| 20 | + Forms\Components\TextInput::make('name') |
| 21 | + ->required() |
| 22 | + ->maxLength(255), |
| 23 | + Forms\Components\ToggleButtons::make('status') |
| 24 | + ->inline() |
| 25 | + ->columnSpanFull() |
| 26 | + ->options(ComponentStatusEnum::class) |
| 27 | + ->required(), |
| 28 | + Forms\Components\MarkdownEditor::make('description') |
| 29 | + ->maxLength(255) |
| 30 | + ->columnSpanFull(), |
| 31 | + Forms\Components\TextInput::make('link') |
| 32 | + ->url() |
| 33 | + ->hint(__('An optional link to the component.')), |
| 34 | + ]); |
| 35 | + } |
| 36 | + |
| 37 | + public function table(Table $table): Table |
| 38 | + { |
| 39 | + return $table |
| 40 | + ->recordTitleAttribute('name') |
| 41 | + ->columns([ |
| 42 | + Tables\Columns\TextColumn::make('name'), |
| 43 | + Tables\Columns\TextColumn::make('status') |
| 44 | + ->badge() |
| 45 | + ->sortable(), |
| 46 | + Tables\Columns\IconColumn::make('enabled') |
| 47 | + ->boolean() |
| 48 | + ->toggleable(isToggledHiddenByDefault: false), |
| 49 | + ]) |
| 50 | + ->filters([ |
| 51 | + // |
| 52 | + ]) |
| 53 | + ->headerActions([ |
| 54 | + Tables\Actions\CreateAction::make(), |
| 55 | + ]) |
| 56 | + ->actions([ |
| 57 | + Tables\Actions\EditAction::make(), |
| 58 | + Tables\Actions\DeleteAction::make(), |
| 59 | + ]) |
| 60 | + ->bulkActions([ |
| 61 | + Tables\Actions\BulkActionGroup::make([ |
| 62 | + Tables\Actions\DeleteBulkAction::make(), |
| 63 | + ]), |
| 64 | + ]); |
| 65 | + } |
| 66 | +} |
0 commit comments