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

@@ -4,7 +4,6 @@ namespace App\Livewire\Server;
use App\Models\Server;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Support\Collection;
use Livewire\Component;
class Resources extends Component
@@ -15,7 +14,7 @@ class Resources extends Component
public $parameters = [];
public Collection $containers;
public array $unmanagedContainers = [];
public $activeTab = 'managed';
@@ -64,7 +63,7 @@ class Resources extends Component
{
try {
$this->activeTab = 'managed';
$this->containers = $this->server->refresh()->definedResources();
$this->server->refresh();
} catch (\Throwable $e) {
return handleError($e, $this);
}
@@ -74,7 +73,7 @@ class Resources extends Component
{
$this->activeTab = 'unmanaged';
try {
$this->containers = $this->server->loadUnmanagedContainers();
$this->unmanagedContainers = $this->server->loadUnmanagedContainers()->toArray();
} catch (\Throwable $e) {
return handleError($e, $this);
}
@@ -82,14 +81,12 @@ class Resources extends Component
public function mount()
{
$this->containers = collect();
$this->parameters = get_route_parameters();
try {
$this->server = Server::ownedByCurrentTeam()->whereUuid(request()->server_uuid)->first();
if (is_null($this->server)) {
return redirect()->route('server.index');
}
$this->loadManagedContainers();
} catch (\Throwable $e) {
return handleError($e, $this);
}