Fix Maintenance Creation

This commit is contained in:
Jonatan Rek 2024-08-06 17:02:14 +02:00
parent e166932809
commit 13756de3a8
1 changed files with 7 additions and 0 deletions

View File

@ -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');
}