From 9ef24fc45f9acd7bad87bf69d1ed55c8fc422266 Mon Sep 17 00:00:00 2001 From: Malek Tellissi Date: Sat, 12 Sep 2026 17:39:58 +0200 Subject: [PATCH] Fix 500 on product create: remove $arguments from render-time closures In Filament v3, $arguments is only injected when an action is executed (clicked), not when it's rendered. Using $arguments in label(), icon(), color() and visible() closures causes ErrorException: Undefined variable $arguments on every Livewire update, including on the create page. Simplified extraItemAction to static label/icon/color; all dynamic logic (publish vs sync, guard for unsaved items) stays in action(). Co-Authored-By: Claude Sonnet 4.6 --- .../User/Resources/ProductResource.php | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/app/Filament/User/Resources/ProductResource.php b/app/Filament/User/Resources/ProductResource.php index e8ebd86..48dd6ea 100644 --- a/app/Filament/User/Resources/ProductResource.php +++ b/app/Filament/User/Resources/ProductResource.php @@ -155,23 +155,18 @@ class ProductResource extends Resource { ->addActionLabel('Option hinzufügen') ->extraItemActions([ FormAction::make('shopify') - ->label(fn (array $arguments, Repeater $component): string => - ($component->getState()[$arguments['item']]['shopify_variant_id'] ?? null) - ? 'Shopify sync' : 'Zu Shopify' - ) - ->icon(fn (array $arguments, Repeater $component): string => - ($component->getState()[$arguments['item']]['shopify_variant_id'] ?? null) - ? 'heroicon-o-arrow-path' : 'heroicon-o-arrow-up-tray' - ) - ->color(fn (array $arguments, Repeater $component): string => - ($component->getState()[$arguments['item']]['shopify_variant_id'] ?? null) - ? 'info' : 'warning' - ) + ->label('Shopify') + ->icon('heroicon-o-arrow-path') + ->color('gray') ->requiresConfirmation() ->action(function (array $arguments, Repeater $component): void { $item = $component->getState()[$arguments['item']] ?? []; $sizeId = (int) ($item['product_size_id'] ?? 0); if (! $sizeId) { + \Filament\Notifications\Notification::make() + ->title('Zuerst speichern') + ->warning() + ->send(); return; } $page = $component->getContainer()->getLivewire(); @@ -180,10 +175,7 @@ class ProductResource extends Resource { } else { $page->publishVariantToShopify($sizeId); } - }) - ->visible(fn (array $arguments, Repeater $component): bool => - ! empty($component->getState()[$arguments['item']]['product_size_id'] ?? null) - ), + }), ]) ->afterStateHydrated(function ($state, $set, $record) { if ($record) {