From b22d05538e53ffa4d2edbc052272bf8e44a79f43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anna-Sara=20S=C3=A9lea?= Date: Tue, 8 Jul 2025 19:11:27 +0200 Subject: [PATCH] Updated create item category select --- app/Filament/Resources/ItemResource.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/app/Filament/Resources/ItemResource.php b/app/Filament/Resources/ItemResource.php index 61b111e..9733116 100644 --- a/app/Filament/Resources/ItemResource.php +++ b/app/Filament/Resources/ItemResource.php @@ -67,6 +67,7 @@ class ItemResource extends Resource ->schema([ Radio::make('type') ->translateLabel() + ->live() ->options([ 'game' => __('Game'), 'item' => __('Item'), @@ -99,9 +100,20 @@ class ItemResource extends Resource ->default(0) ->hidden(fn ($get): string => $get('type') == 'game' || $get('type') == 'literature' ), Select::make('category_id') - ->label('Category') + ->label('Category items') ->translateLabel() - ->options(Category::all()->pluck('name', 'id')), + ->options(Category::where('type', 'item')->pluck('name', 'id')) + ->hidden(fn ($get): string => $get('type') == 'game' || $get('type') == 'literature' ), + Select::make('category_id') + ->label('Category games') + ->translateLabel() + ->options(Category::where('type', 'game')->pluck('name', 'id')) + ->hidden(fn ($get): string => $get('type') == 'item' || $get('type') == 'literature' ), + Select::make('category_id') + ->label('Category literature') + ->translateLabel() + ->options(Category::where('type', 'literature')->pluck('name', 'id')) + ->hidden(fn ($get): string => $get('type') == 'game' || $get('type') == 'item' ), TextInput::make('cost') ->label('Price') ->translateLabel()