From 13756de3a856e7e7da70849304ee16b38e302a25 Mon Sep 17 00:00:00 2001 From: Jonatan Rek Date: Tue, 6 Aug 2024 17:02:14 +0200 Subject: [PATCH] Fix Maintenance Creation --- app/Livewire/Maintenance/Form.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/Livewire/Maintenance/Form.php b/app/Livewire/Maintenance/Form.php index 2fa945b..95df2d0 100644 --- a/app/Livewire/Maintenance/Form.php +++ b/app/Livewire/Maintenance/Form.php @@ -62,6 +62,13 @@ public function store() $hosts = Host::whereIn('id', $this->hosts)->get(); foreach ($hosts as $key => $host) { $maintenance->hosts()->attach($host); + $tasks = Host::whereIn('id', $this->hosts_tasks[$host->id])->get(); + foreach ($tasks as $task) { + $maintenance->tasks()->create([ + 'task_id' => $task->id, + 'host_id' => $host->id, + ]); + } } $this->dispatch('closeModal'); }