Files
nutzwerte_fi4/app/Filament/Resources/Projektes/RelationManagers/ProjektPlatzhalterRelationManager.php
T

69 lines
2.5 KiB
PHP

<?php
namespace App\Filament\Resources\Projektes\RelationManagers;
use App\Actions\Create\CreatePlatzhalter;
use Filament\Actions\Action;
use Filament\Actions\EditAction;
use Filament\Forms\Components\TextInput;
use Filament\Resources\RelationManagers\RelationManager;
use Filament\Schemas\Schema;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Columns\TextInputColumn;
use Filament\Tables\Table;
class ProjektPlatzhalterRelationManager extends RelationManager
{
protected static string $relationship = 'projekt_platzhalters';
protected static ?string $title = 'Platzhalter';
protected static ?string $navigationLabel = 'Platzhalter';
protected static ?string $modelLabel = 'Platzhalter';
protected static ?string $pluralModelLabel = 'Platzhalter';
public function form(Schema $schema): Schema
{
return $schema
->components([
TextInput::make('platzhalter')
->required()
->maxLength(255),
TextInput::make('platzhaltertext')
->required()
->maxLength(255),
]);
}
public function table(Table $table): Table
{
return $table
->recordTitleAttribute('name')
->emptyStateDescription('Generiere die Platzhalter aus dem Inhaltsverzeichnis.')
->columns([
TextColumn::make('platzhalter')
->searchable(),
TextInputColumn::make('platzhaltertext')
->extraInputAttributes(['onClick' => 'this.select()'])
->label('Platzhalter Text')
->searchable(),
])
->headerActions([
Action::make('generate')
->action(fn (CreatePlatzhalter $createPlatzhalter) => $createPlatzhalter->create($this->ownerRecord))
->requiresConfirmation()
->modalHeading('Platzhalter neu generieren')
->modalDescription('Bestehende Platzhalter bleiben erhalten, neue werden hinzugefügt und nicht mehr verwendete werden gelöscht.')
->modalSubmitActionLabel('Ja, neu generieren')
->label('Generieren')
->tooltip('Platzhalter werden neu eingelesen.')
->icon('heroicon-o-cog-8-tooth'),
])
->recordActions([
// EditAction::make()->iconButton(),
]);
}
}