ProjektObjekteImDetailRelationManager calc nutzwerte all at once
This commit is contained in:
1 parent
245136c3af
commit
aa7d95ac5f
1 file changed
+16
-3
+16
-3
@@ -142,9 +142,22 @@ class ProjektObjekteImDetailRelationManager extends RelationManager
|
|||||||
CreateAction::make()
|
CreateAction::make()
|
||||||
->icon('phosphor-file-plus')
|
->icon('phosphor-file-plus')
|
||||||
->createAnother(false),
|
->createAnother(false),
|
||||||
// Action::make('nutzwerte')
|
Action::make('nutzwerte')
|
||||||
// ->label('Nutzwerte')
|
->label('Nutzwerte')
|
||||||
// ->icon('phosphor-gear'),
|
->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([
|
->recordActions([
|
||||||
EditAction::make()->iconButton()
|
EditAction::make()->iconButton()
|
||||||
|
|||||||
Reference in new issue
Block a user