Updated create item category select

This commit is contained in:
Anna-Sara Sélea 2025-07-08 19:11:27 +02:00
parent de94eb4e30
commit b22d05538e

View file

@ -67,6 +67,7 @@ class ItemResource extends Resource
->schema([ ->schema([
Radio::make('type') Radio::make('type')
->translateLabel() ->translateLabel()
->live()
->options([ ->options([
'game' => __('Game'), 'game' => __('Game'),
'item' => __('Item'), 'item' => __('Item'),
@ -99,9 +100,20 @@ class ItemResource extends Resource
->default(0) ->default(0)
->hidden(fn ($get): string => $get('type') == 'game' || $get('type') == 'literature' ), ->hidden(fn ($get): string => $get('type') == 'game' || $get('type') == 'literature' ),
Select::make('category_id') Select::make('category_id')
->label('Category') ->label('Category items')
->translateLabel() ->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') TextInput::make('cost')
->label('Price') ->label('Price')
->translateLabel() ->translateLabel()