72 lines
2.7 KiB
PHP
72 lines
2.7 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\Projektes\RelationManagers;
|
|
|
|
use App\Actions\Create\CreatePlatzhalter;
|
|
use Filament\Actions\Action;
|
|
use Filament\Forms\Components\Hidden;
|
|
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([
|
|
Hidden::make('added_manuel')->default(1),
|
|
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.')
|
|
->defaultPaginationPageOption(50)
|
|
->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))
|
|
->hidden(fn (): bool => $this->ownerRecord->bezahlt_am ? false : true)
|
|
->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(),
|
|
]);
|
|
}
|
|
}
|