update os

This commit is contained in:
pbao9
2026-02-02 10:17:51 +07:00
parent 34575b2d96
commit d3b264262b
4 changed files with 45 additions and 10 deletions
+15 -4
View File
@@ -1,6 +1,11 @@
@php
// Fix: Get os_group_id from the relationship correctly
$selectedOsGroupId = old('os_group_id') ?? ($model?->os?->os_group_id ?? null);
$selectedOsGroupId = old('os_group_id') ?? ($model?->os_group_id ?? null);
$lists = collect();
if ($model && $model->osGroup) {
$lists = collect([$model->osGroup]);
}
@endphp
@@ -12,7 +17,12 @@ $selectedOsGroupId = old('os_group_id') ?? ($model?->os?->os_group_id ?? null);
@if ($selectedOsGroupId && $lists)
@foreach ($lists->all() as $item)
@if ($item->id == $selectedOsGroupId)
<option value="{{ $item->id }}" selected>{{ $item->name }}</option>
<option value="{{ $item->id }}" selected>
{{ $item->name }}
@if($item->host)
- {{ $item->host->name }} ({{ $item->host->host_id }})
@endif
</option>
@endif
@endforeach
@endif
@@ -72,8 +82,9 @@ $selectedOsGroupId = old('os_group_id') ?? ($model?->os?->os_group_id ?? null);
let options = '<option value="">--- Chọn OS Group ---</option>';
response.data.forEach(os => {
const selected = preselect == os.id ? 'selected' : '';
const hostInfo = os.host ? ` - ${os.host.name} (${os.host.host_id})` : '';
options +=
`<option value="${os.id}" ${selected}>${os.name}</option>`;
`<option value="${os.id}" ${selected}>${os.name}${hostInfo}</option>`;
});
$osGroup.html(options).prop('disabled', false);