diff --git a/app/Http/Controllers/MaintenanceController.php b/app/Http/Controllers/MaintenanceController.php
index b70a708..16a524e 100644
--- a/app/Http/Controllers/MaintenanceController.php
+++ b/app/Http/Controllers/MaintenanceController.php
@@ -3,6 +3,7 @@
namespace App\Http\Controllers;
use App\Models\MaintenanceHistory;
+use Illuminate\Http\Request;
class MaintenanceController extends BaseController
{
@@ -22,4 +23,12 @@ public function plannedDetail(MaintenanceHistory $maintenance_history)
'maintenance_history' => $maintenance_history,
]);
}
+
+ public function plannedDetailPut(Request $request, MaintenanceHistory $maintenance_history)
+ {
+ return view('maintenance.planned-detail-done', [
+ 'maintenance_history' => $maintenance_history,
+ 'maintenance_state' => $request->input('test'),
+ ]);
+ }
}
diff --git a/app/Livewire/Maintenance/Form.php b/app/Livewire/Maintenance/Form.php
index 95df2d0..3ce96e5 100644
--- a/app/Livewire/Maintenance/Form.php
+++ b/app/Livewire/Maintenance/Form.php
@@ -55,6 +55,17 @@ public function mount($model = null)
}
}
+ public function updatedHosts($value)
+ {
+ foreach ($this->hosts_tasks as $host_id => $tasks) {
+ if (in_array($host_id, $this->hosts)) {
+ continue;
+ }
+
+ unset($this->hosts_tasks[$host_id]);
+ }
+ }
+
public function store()
{
$validatedData = $this->validate();
@@ -62,7 +73,7 @@ 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();
+ $tasks = Task::whereIn('id', $this->hosts_tasks[$host->id])->get();
foreach ($tasks as $task) {
$maintenance->tasks()->create([
'task_id' => $task->id,
diff --git a/resources/views/livewire/maintenance/form.blade.php b/resources/views/livewire/maintenance/form.blade.php
index e673b14..e906b69 100644
--- a/resources/views/livewire/maintenance/form.blade.php
+++ b/resources/views/livewire/maintenance/form.blade.php
@@ -4,12 +4,11 @@
{!! $maintenance_history->maintenance->description !!}{{ __('Planned Maintenance') }}
+
{!! $maintenance_history->maintenance->description !!}
-{!! $historyTasks->maintenanceTask->task->description !!}
- @endforeach +{!! $historyTasks->maintenanceTask->task->description !!}
+ @endforeach +