ProjektObjekteImDetailRelationManager calc nutzwerte all at once

This commit is contained in:
salam committed 2026-03-17 20:31:45 +01:00
1 parent 245136c3af
commit aa7d95ac5f
1 file changed
+16 -3
@@ -142,9 +142,22 @@ class ProjektObjekteImDetailRelationManager extends RelationManager
CreateAction::make()
->icon('phosphor-file-plus')
->createAnother(false),
// Action::make('nutzwerte')
// ->label('Nutzwerte')
// ->icon('phosphor-gear'),
Action::make('nutzwerte')
->label('Nutzwerte')
->icon('phosphor-gear')
->action(function () {
$res = ProjektObjekteImDetail::with('methode')
->where('projekte_id', $this->getOwnerRecord()->id)
->get();
foreach ($res as $row) {
ProjektObjekteImDetail::where('id', $row->id)
->update(['nutzwert' => $row->flaeche * $row->methode->faktor]);
}
})->after(function (Component $livewire) {
$livewire->dispatch('refreshProjektObjekteImDetail');
}),
])
->recordActions([
EditAction::make()->iconButton()