Fix server resources tab 500 error with mixed model types

The Resources tab threw a "Queueing collections with multiple model types is not supported" error because the Livewire component was storing a mixed-type Eloquent collection (Applications, Databases, Services) as a public property, causing Livewire's serialization to fail.

Fixed by: storing only the unmanaged containers array in the component, and calling definedResources() directly in the Blade view for the managed tab.

Fixes #7666

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
Andras Bacsai
2025-12-17 18:13:55 +01:00
parent 1b3be5bef6
commit 4b65b02103
4 changed files with 61 additions and 26 deletions

View File

@@ -32,8 +32,11 @@
</div>
</div>
</div>
@if ($containers->count() > 0)
@if ($activeTab === 'managed')
@if ($activeTab === 'managed')
@php
$managedResources = $server->definedResources()->sortBy('name', SORT_NATURAL);
@endphp
@if ($managedResources->count() > 0)
<div class="flex flex-col">
<div class="flex flex-col">
<div class="overflow-x-auto">
@@ -59,7 +62,7 @@
</tr>
</thead>
<tbody>
@forelse ($server->definedResources()->sortBy('name',SORT_NATURAL) as $resource)
@foreach ($managedResources as $resource)
<tr>
<td class="px-5 py-4 text-sm whitespace-nowrap">
{{ data_get($resource->project(), 'name') }}
@@ -83,8 +86,7 @@
@endif
</td>
</tr>
@empty
@endforelse
@endforeach
</tbody>
</table>
</div>
@@ -92,7 +94,11 @@
</div>
</div>
</div>
@elseif ($activeTab === 'unmanaged')
@else
<div>No managed resources found.</div>
@endif
@elseif ($activeTab === 'unmanaged')
@if (count($unmanagedContainers) > 0)
<div class="flex flex-col">
<div class="flex flex-col">
<div class="overflow-x-auto">
@@ -116,7 +122,7 @@
</tr>
</thead>
<tbody>
@forelse ($containers->sortBy('name',SORT_NATURAL) as $resource)
@foreach (collect($unmanagedContainers)->sortBy('name', SORT_NATURAL) as $resource)
<tr>
<td class="px-5 py-4 text-sm whitespace-nowrap">
{{ data_get($resource, 'Names') }}
@@ -146,19 +152,15 @@
@endif
</td>
</tr>
@empty
@endforelse
@endforeach
</tbody>
</table>
</div>
</div>
</div>
</div>
@endif
@else
@if ($activeTab === 'managed')
<div>No managed resources found.</div>
@elseif ($activeTab === 'unmanaged')
</div>
@else
<div>No unmanaged resources found.</div>
@endif
@endif