F
Filament3w ago
kool

Switching Between Tabs Returns Schema Containter Initialization Issue

Dears, I have upgraded from laravel 10 to laravel 12 and it was a quite of an upgrade! So I have faced an issue inside a resource where switching between tabs resulting in initialization issue (Find attached callstack) The issue appears when: 1. In currently problamtic, go to previously problematic 2. Go back again to currently problematic 3. Boom! Current Versions - Filament Version: 4.0.15 - Laravel Framework 12.28.1
No description
4 Replies
kool
koolOP3w ago
Listing.php
<?php

namespace App\Filament\Pages\Order\Problematic;

use Filament\Schemas\Components\Tabs\Tab;
use App\Filament\Base\Order\Pages\ListOrders;
use App\Filament\Resources\OrderProblematicResource;
use App\Models\Order;
use App\Services\Order\GetOldProblematicOrdersService;

class Listing extends ListOrders
{
public const CURRENTLY_PROBLEMATIC = 'currently-problematic';

public const PREVIOUSLY_PROBLEMATIC = 'previously-problematic';

public ?string $activeTab = self::CURRENTLY_PROBLEMATIC;

protected static string $resource = OrderProblematicResource::class;

protected static ?string $title = 'Problematic Orders';

public function getTabs(): array
{
return [
self::CURRENTLY_PROBLEMATIC => Tab::make()
->label('Currently Problematic'),
self::PREVIOUSLY_PROBLEMATIC => Tab::make()
->label('Previously Problematic')
->modifyQueryUsing(fn (GetOldProblematicOrdersService $getOrdersService) => $getOrdersService
->execute(Order::query())
->withMissingItems()),
];
}
}
<?php

namespace App\Filament\Pages\Order\Problematic;

use Filament\Schemas\Components\Tabs\Tab;
use App\Filament\Base\Order\Pages\ListOrders;
use App\Filament\Resources\OrderProblematicResource;
use App\Models\Order;
use App\Services\Order\GetOldProblematicOrdersService;

class Listing extends ListOrders
{
public const CURRENTLY_PROBLEMATIC = 'currently-problematic';

public const PREVIOUSLY_PROBLEMATIC = 'previously-problematic';

public ?string $activeTab = self::CURRENTLY_PROBLEMATIC;

protected static string $resource = OrderProblematicResource::class;

protected static ?string $title = 'Problematic Orders';

public function getTabs(): array
{
return [
self::CURRENTLY_PROBLEMATIC => Tab::make()
->label('Currently Problematic'),
self::PREVIOUSLY_PROBLEMATIC => Tab::make()
->label('Previously Problematic')
->modifyQueryUsing(fn (GetOldProblematicOrdersService $getOrdersService) => $getOrdersService
->execute(Order::query())
->withMissingItems()),
];
}
}
kool
koolOP3w ago
kool
koolOP3w ago
kool
koolOP3w ago
I noticed the tab query parameter does not change or added ? Alright, I solved the issue. It seems the way of injecting properties inside modifyQueryUsing has been changed (not sure) but If any of the devs have clear reasoning. Please do. Thanks Solution
->modifyQueryUsing(function (OrderBuilder $query) {
return app(GetOldProblematicOrdersService::class)>execute(Order::query());
}),
->modifyQueryUsing(function (OrderBuilder $query) {
return app(GetOldProblematicOrdersService::class)>execute(Order::query());
}),

Did you find this page helpful?