109 lines
4.2 KiB
PHP
109 lines
4.2 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\Projektes\RelationManagers;
|
|
|
|
use Filament\Actions\BulkActionGroup;
|
|
use Filament\Actions\CreateAction;
|
|
use Filament\Actions\DeleteAction;
|
|
use Filament\Actions\DeleteBulkAction;
|
|
use Filament\Actions\EditAction;
|
|
use Filament\Forms\Components\TextInput;
|
|
use Filament\Resources\RelationManagers\RelationManager;
|
|
use Filament\Schemas\Schema;
|
|
use Filament\Tables\Columns\Summarizers\Sum;
|
|
use Filament\Tables\Columns\TextColumn;
|
|
use Filament\Tables\Columns\TextInputColumn;
|
|
use Filament\Tables\Table;
|
|
use Illuminate\Support\HtmlString;
|
|
use Livewire\Component;
|
|
|
|
class ProjektAllgemeinflaechensRelationManager extends RelationManager
|
|
{
|
|
protected static string $relationship = 'projekt_allgemeinflaechens';
|
|
|
|
protected static ?string $title = 'Allgemeinflächen';
|
|
|
|
protected static ?string $navigationLabel = 'Allgemeinflächen';
|
|
|
|
protected static ?string $modelLabel = 'Allgemeinflächen';
|
|
|
|
protected static ?string $pluralModelLabel = 'Allgemeinflächen';
|
|
|
|
public function form(Schema $schema): Schema
|
|
{
|
|
return $schema
|
|
->components([
|
|
TextInput::make('geschoss')
|
|
->required()
|
|
->maxLength(255),
|
|
TextInput::make('raumart')
|
|
->required()
|
|
->maxLength(255),
|
|
TextInput::make('flaeche')
|
|
->suffix(new HtmlString(' m²'))
|
|
->numeric()
|
|
->label('Fläche')
|
|
->rules(['required', 'flaeche' => 'decimal:2'])
|
|
->validationMessages([
|
|
'required' => 'Die Eingabe einer Fläche ist erforderlich.',
|
|
'decimal' => 'Für die Fläche sind zwei Dezimalstellen erforderlich.',
|
|
]),
|
|
])->columns(3);
|
|
}
|
|
|
|
public function table(Table $table): Table
|
|
{
|
|
return $table
|
|
->emptyStateDescription('Schalten Sie das Projekt frei und importieren Sie die Daten der Allgemeinflächen.')
|
|
->striped()
|
|
->recordTitleAttribute('geschoss')
|
|
->columns([
|
|
TextColumn::make('geschoss')->searchable(),
|
|
TextColumn::make('raumart')->searchable(),
|
|
TextInputColumn::make('flaeche')
|
|
->extraInputAttributes(['onClick' => 'this.select()'])
|
|
->summarize(Sum::make()->label('Gesammt')->numeric(
|
|
decimalPlaces: 2,
|
|
)->suffix(new HtmlString(' m²')))
|
|
->suffix(new HtmlString(' m²'))
|
|
->width('2rem')
|
|
->rules(['required', 'flaeche' => 'decimal:2'])
|
|
->alignment('right')
|
|
->label('Fläche')
|
|
->searchable()
|
|
->validationMessages([
|
|
'required' => 'Die Eingabe einer Fläche ist erforderlich.',
|
|
'decimal' => 'Für die Fläche sind zwei Dezimalstellen erforderlich.',
|
|
])
|
|
->afterStateUpdated(function (Component $livewire) {
|
|
$livewire->dispatch('refreshProjektAllgemeinflaechen');
|
|
}),
|
|
])
|
|
->filters([
|
|
//
|
|
])
|
|
->headerActions([
|
|
CreateAction::make()
|
|
->icon('phosphor-file-plus')
|
|
->createAnother(false),
|
|
])
|
|
->recordActions([
|
|
EditAction::make()->iconButton()
|
|
->after(function (Component $livewire) {
|
|
$livewire->dispatch('refreshProjektAllgemeinflaechen');
|
|
}),
|
|
DeleteAction::make()->iconButton()->after(function (Component $livewire) {
|
|
$livewire->dispatch('refreshProjektAllgemeinflaechen');
|
|
}),
|
|
])
|
|
->toolbarActions([
|
|
BulkActionGroup::make([
|
|
DeleteBulkAction::make()
|
|
->after(function (Component $livewire) {
|
|
$livewire->dispatch('refreshProjektAllgemeinflaechen');
|
|
}),
|
|
]),
|
|
]);
|
|
}
|
|
}
|