Beistrich bei Eingabe statt Punkt
This commit is contained in:
1 parent
096c8cf091
commit
ddbf171881
15 files changed
+407
-305
No files matched your search
+73
-29
@@ -10,10 +10,12 @@ use App\Models\ProjektObjekteImDetail;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\BulkAction;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\RelationManagers\RelationManager;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Columns\SelectColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Columns\TextInputColumn;
|
||||
@@ -37,51 +39,93 @@ class ProjektMethodesRelationManager extends RelationManager
|
||||
|
||||
protected static ?string $pluralModelLabel = 'Raum Methoden';
|
||||
|
||||
public function table(Table $table): Table
|
||||
public function form(Schema $schema): Schema
|
||||
{
|
||||
return $table
|
||||
->striped()
|
||||
->recordTitleAttribute('raumart')
|
||||
->columns([
|
||||
SelectColumn::make('methode_id')
|
||||
return $schema
|
||||
->components([
|
||||
Select::make('methode_id')
|
||||
->label('Methoden')
|
||||
->optionsRelationship('methode', 'name')
|
||||
->preloadOptions()
|
||||
->options(Methode::pluck('name', 'id'))
|
||||
->rules(['required'])
|
||||
->afterStateUpdated(function (Component $livewire) {
|
||||
$livewire->dispatch('refreshMethods');
|
||||
})->validationMessages([
|
||||
'required' => 'Die Eingabe einer Methode ist erforderlich.',
|
||||
]),
|
||||
SelectColumn::make('aufstellung_id')
|
||||
Select::make('aufstellung_id')
|
||||
->label('Aufstellung')
|
||||
->optionsRelationship('aufstellung', 'name')
|
||||
->preloadOptions()
|
||||
->rules(['required'])
|
||||
->options(Aufstellung::pluck('name', 'id'))
|
||||
->afterStateUpdated(function (Component $livewire) {
|
||||
$livewire->dispatch('refreshMethods');
|
||||
})->validationMessages([
|
||||
'required' => 'Die Eingabe einer Aufstellung ist erforderlich.',
|
||||
}),
|
||||
TextInput::make('faktor')
|
||||
->suffixIcon('phosphor-function')
|
||||
->numeric()
|
||||
->label('Fläche')
|
||||
->rules(['required'])
|
||||
->validationMessages([
|
||||
'required' => 'Die Eingabe einer Fläche ist erforderlich.',
|
||||
]),
|
||||
])->columns(3);
|
||||
}
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->striped()
|
||||
->recordTitleAttribute('raumart')
|
||||
->columns([
|
||||
TextColumn::make('methode.name')
|
||||
->searchable(),
|
||||
TextColumn::make('aufstellung.name')
|
||||
->searchable(),
|
||||
// SelectColumn::make('methode_id')
|
||||
// ->label('Methoden')
|
||||
// ->optionsRelationship('methode', 'name')
|
||||
// ->preloadOptions()
|
||||
// ->rules(['required'])
|
||||
// ->afterStateUpdated(function (Component $livewire) {
|
||||
// $livewire->dispatch('refreshMethods');
|
||||
// })->validationMessages([
|
||||
// 'required' => 'Die Eingabe einer Methode ist erforderlich.',
|
||||
// ]),
|
||||
// SelectColumn::make('aufstellung_id')
|
||||
// ->label('Aufstellung')
|
||||
// ->optionsRelationship('aufstellung', 'name')
|
||||
// ->preloadOptions()
|
||||
// ->rules(['required'])
|
||||
// ->afterStateUpdated(function (Component $livewire) {
|
||||
// $livewire->dispatch('refreshMethods');
|
||||
// })->validationMessages([
|
||||
// 'required' => 'Die Eingabe einer Aufstellung ist erforderlich.',
|
||||
// ]),
|
||||
|
||||
TextColumn::make('raumart')
|
||||
->searchable(),
|
||||
TextInputColumn::make('faktor')
|
||||
->extraInputAttributes(['onClick' => 'this.select()'])
|
||||
->suffixIcon('phosphor-function')
|
||||
->width('1rem')
|
||||
->rules(['required', 'faktor' => 'decimal:0,2'])
|
||||
TextColumn::make('faktor')
|
||||
->numeric(2, ',')
|
||||
->icon('phosphor-function')
|
||||
->searchable()
|
||||
->afterStateUpdated(function ($record) {
|
||||
$objects = ProjektObjekteImDetail::where('projekte_id', $record['projekte_id'])->where('raumart', $record['raumart'])->get();
|
||||
foreach ($objects as $value) {
|
||||
$nutzwert = round($record['faktor'] * $value->flaeche, 2);
|
||||
ProjektObjekteImDetail::where('id', $value->id)->update(['nutzwert' => $nutzwert]);
|
||||
}
|
||||
})->validationMessages([
|
||||
'required' => 'Die Eingabe eines Faktors ist erforderlich.',
|
||||
'decimal' => 'Für den Faktors sind zwei Dezimalstellen erforderlich.',
|
||||
]),
|
||||
->label('Faktor'),
|
||||
// TextInputColumn::make('faktor')
|
||||
// ->extraInputAttributes(['onClick' => 'this.select()'])
|
||||
// ->suffixIcon('phosphor-function')
|
||||
// ->width('1rem')
|
||||
// ->rules(['required', 'faktor' => 'decimal:0,2'])
|
||||
// ->searchable()
|
||||
// ->afterStateUpdated(function ($record) {
|
||||
// $objects = ProjektObjekteImDetail::where('projekte_id', $record['projekte_id'])->where('raumart', $record['raumart'])->get();
|
||||
// foreach ($objects as $value) {
|
||||
// $nutzwert = round($record['faktor'] * $value->flaeche, 2);
|
||||
// ProjektObjekteImDetail::where('id', $value->id)->update(['nutzwert' => $nutzwert]);
|
||||
// }
|
||||
// })->validationMessages([
|
||||
// 'required' => 'Die Eingabe eines Faktors ist erforderlich.',
|
||||
// 'decimal' => 'Für den Faktors sind zwei Dezimalstellen erforderlich.',
|
||||
// ]),
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make()->iconButton(),
|
||||
])
|
||||
->filters([
|
||||
SelectFilter::make('methodes')
|
||||
|
||||
Reference in new issue
Block a user