Files
nutzwerte_fi4/app/Filament/Resources/Projektes/Schemas/ProjekteForm.php
T
2025-11-16 13:08:51 +01:00

109 lines
6.3 KiB
PHP

<?php
namespace App\Filament\Resources\Projektes\Schemas;
use App\Enums\ProjektStatus;
use App\Models\Projekte;
use Filament\Actions\Action;
use Filament\Forms\Components\DatePicker;
use Filament\Forms\Components\Radio;
use Filament\Forms\Components\RichEditor;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Components\Tabs;
use Filament\Schemas\Components\Tabs\Tab;
use Filament\Schemas\Schema;
class ProjekteForm
{
public static function configure(Schema $schema): Schema
{
return $schema
->components([
Section::make('Projekt Daten')
->label(fn (?Projekte $record): ?string => ($record?->created_at) ? 'Erstellt: '.$record?->created_at->diffForHumans().', Geändert: '.$record?->updated_at->diffForHumans() : '')
->collapsed(fn ($operation) => $operation == 'create' ? false : true)
->icon('heroicon-o-rectangle-stack')
->schema([
Tabs::make('Tabs')
->contained(false)
->tabs([
Tab::make('Benennung')
->schema([
TextInput::make('offizieller_name')
->label('Offizieller Name')
->suffixAction(
Action::make('copy')
->tooltip('Kopieren')
->icon('heroicon-s-clipboard-document-check')
->action(function ($livewire, $state) {
$livewire->js('window.navigator.clipboard.writeText("'.$state.'");');
})
)
->belowContent([
'Als Platzhalter "###OFFIZIELLER_NAME###"',
])
->required(),
TextInput::make('interner_name')
->label('Interner Name')
->suffixAction(
Action::make('copy')
->tooltip('Kopieren')
->icon('heroicon-s-clipboard-document-check')
->action(function ($livewire, $state) {
$livewire->js('window.navigator.clipboard.writeText("'.$state.'");');
})
)
->belowContent([
'Als Platzhalter "###INTERNER_NAME###"',
])
->required(),
TextInput::make('ort')->required()->suffix('am')
->belowContent([
'Als Platzhalter "###ORT###"',
]),
DatePicker::make('erstellung')
->label('Datum der Erstellung')
->required()
->belowContent([
'Als Platzhalter "###DATUM###"',
]),
])->columns(2),
Tab::make('Zuordnung')
->schema([
Select::make('gutachter_id')->relationship(name: 'gutachter', titleAttribute: 'company')->required(),
Select::make('auftraggeber_id')
->searchable()
->loadingMessage('Lade Auftraggeber...')
->relationship(name: 'auftraggeber', titleAttribute: 'company')
->required(),
Radio::make('status')->options(ProjektStatus::class)->required(),
]),
Tab::make('Beschreibung')
->schema([
RichEditor::make('beschreibung')
->extraInputAttributes(['style' => 'min-height: 20rem; max-height: 50vh; overflow-y: auto;'])
->toolbarButtons([
['bold', 'italic', 'underline', 'strike', 'subscript', 'superscript', 'link', 'textColor', 'clearFormatting'],
['alignStart', 'alignCenter', 'alignEnd'],
['bulletList', 'orderedList', 'table'],
['undo', 'redo'],
])->floatingToolbars([
'table' => [
'tableAddColumnBefore', 'tableAddColumnAfter', 'tableDeleteColumn',
'tableAddRowBefore', 'tableAddRowAfter', 'tableDeleteRow',
'tableMergeCells', 'tableSplitCell',
'tableToggleHeaderRow',
'tableDelete',
],
])
->columnSpan(2),
]),
]),
])->columnSpanFull(),
]);
}
}