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 @@ class Form extends Component $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'); }