listTaxonomyFormSchema($torrentMode); $specialTaxonomySchema = $searchBoxRep->listTaxonomyFormSchema($specialMode); $modeOptions = SearchBox::listModeOptions(); return $schema ->components([ TextInput::make('name') ->label(__('label.name')) ->required() ->helperText(__('label.second_icon.name_help')) , TextInput::make('image') ->label(__('label.second_icon.image')) ->required() ->helperText(__('label.second_icon.image_help')) , TextInput::make('class_name') ->label(__('label.second_icon.class_name')) ->helperText(__('label.second_icon.class_name_help')) , Select::make('mode') ->options($modeOptions) ->label(__('label.search_box.taxonomy.mode')) ->helperText(__('label.search_box.taxonomy.mode_help')) ->reactive() , Section::make(__('label.second_icon.select_section')) ->id("taxonomy_$torrentMode") ->schema($torrentTaxonomySchema) ->columns(4) ->hidden(fn (Get $get) => $get('mode') != $torrentMode) , Section::make(__('label.second_icon.select_section')) ->id("taxonomy_$specialMode") ->schema($specialTaxonomySchema) ->columns(4) ->hidden(fn (Get $get) => $get('mode') != $specialMode) , ]); } public static function table(Table $table): Table { $columns = [ TextColumn::make('id'), TextColumn::make('search_box.name') ->label(__('label.search_box.label')) ->formatStateUsing(fn ($record) => $record->search_box->name ?? 'All') , TextColumn::make('name')->label(__('label.name')), TextColumn::make('image')->label(__('label.second_icon.image')), TextColumn::make('class_name')->label(__('label.second_icon.class_name')), ]; $taxonomyList = self::listTaxonomy(); foreach (SearchBox::$taxonomies as $torrentField => $taxonomyTableModel) { $columns[] = TextColumn::make($torrentField)->formatStateUsing(function ($state) use ($taxonomyList, $torrentField) { return $taxonomyList[$torrentField]->get($state); }); } return $table ->columns($columns) ->filters([ // ]) ->recordActions([ EditAction::make(), DeleteAction::make(), ]) ->toolbarActions([ DeleteBulkAction::make(), ]); } private static function listTaxonomy() { static $taxonomyList = []; if (empty($taxonomyList)) { foreach (SearchBox::$taxonomies as $torrentField => $taxonomyTableModel) { $taxonomyList[$torrentField] = NexusDB::table($taxonomyTableModel['table'])->pluck('name', 'id'); } } return $taxonomyList; } public static function getRelations(): array { return [ // ]; } public static function getPages(): array { return [ 'index' => ListSecondIcons::route('/'), 'create' => CreateSecondIcon::route('/create'), 'edit' => EditSecondIcon::route('/{record}/edit'), ]; } }