104 lines
3.6 KiB
PHP
104 lines
3.6 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\Projektes\RelationManagers;
|
|
|
|
use App\Filament\Imports\AllgemeinflaechenImporter;
|
|
use Filament\Actions\BulkActionGroup;
|
|
use Filament\Actions\CreateAction;
|
|
use Filament\Actions\DeleteAction;
|
|
use Filament\Actions\DeleteBulkAction;
|
|
use Filament\Actions\EditAction;
|
|
use Filament\Actions\ImportAction;
|
|
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 Illuminate\Validation\Rules\File;
|
|
|
|
class AllgemeinflaechensRelationManager extends RelationManager
|
|
{
|
|
protected static string $relationship = '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')
|
|
->required()
|
|
->maxLength(255),
|
|
])->columns(3);
|
|
}
|
|
|
|
public function table(Table $table): Table
|
|
{
|
|
return $table
|
|
->striped()
|
|
->recordTitleAttribute('geschoss')
|
|
->columns([
|
|
TextColumn::make('geschoss')->searchable(),
|
|
TextColumn::make('raumart')->searchable(),
|
|
TextInputColumn::make('flaeche')
|
|
->summarize(Sum::make()->label('Gesammt')->numeric(
|
|
decimalPlaces: 2,
|
|
)->suffix(new HtmlString(' m²')))
|
|
->suffix(new HtmlString(' m²'))
|
|
->width('2rem')
|
|
->rules(['required', 'price' => 'decimal:2'])
|
|
->alignment('right')
|
|
// ->formatStateUsing(fn ($state) => "{$state} m²")
|
|
->label('Fläche')
|
|
->searchable(),
|
|
])
|
|
->filters([
|
|
//
|
|
])
|
|
->headerActions([
|
|
CreateAction::make()
|
|
->icon('phosphor-file-plus'),
|
|
ImportAction::make()
|
|
->importer(AllgemeinflaechenImporter::class)
|
|
->modalHeading('Allgemeinflächen Import')
|
|
// ->modalSubmitActionLabel('Yes, delete it')
|
|
->label('Hochladen')
|
|
->icon('phosphor-upload')
|
|
->color('info')
|
|
->options([
|
|
'projekte_id' => $this->getOwnerRecord()->id,
|
|
])
|
|
->fileRules([
|
|
File::types(['csv', 'txt'])->max(1024),
|
|
]),
|
|
])
|
|
->recordActions([
|
|
EditAction::make()->iconButton()->color('gray'),
|
|
DeleteAction::make()->iconButton(),
|
|
])
|
|
->toolbarActions([
|
|
BulkActionGroup::make([
|
|
DeleteBulkAction::make(),
|
|
]),
|
|
]);
|
|
}
|
|
}
|