schema([ TextInput::make('name') ->label(__('filament.resource.api_provider.form.name')) ->required() ->maxLength(255), Toggle::make('enabled') ->label(__('filament.resource.api_provider.form.enabled')) ->default(true), TextInput::make('api_url') ->label(__('filament.resource.api_provider.form.api_url')) ->required() ->url() ->maxLength(255), TextInput::make('username') ->label(__('filament.resource.api_provider.form.username')) ->nullable() ->maxLength(255), TextInput::make('password') ->label(__('filament.resource.api_provider.form.password')) ->password() ->nullable() ->maxLength(255), TextInput::make('token') ->label(__('filament.resource.api_provider.form.token')) ->nullable() ->maxLength(255), Select::make('plugin') ->options($plugins) ->nullable() ->label(__('filament.resource.api_provider.form.plugin')), ]); } public static function table(Table $table): Table { return $table ->columns([ TextColumn::make('name')->label(__('filament.resource.api_provider.table.name'))->searchable()->sortable(), IconColumn::make('enabled') ->label(__('filament.resource.api_provider.table.enabled')) ->boolean(), TextColumn::make('api_url')->label(__('filament.resource.api_provider.table.api_url'))->searchable(), TextColumn::make('plugin')->label(__('filament.resource.api_provider.table.plugin'))->searchable()->sortable(), ]) ->filters([ // ]) ->actions([ Tables\Actions\EditAction::make(), ]) ->bulkActions([ Tables\Actions\BulkActionGroup::make([ Tables\Actions\DeleteBulkAction::make(), ]), ]) ->emptyStateActions([ Tables\Actions\CreateAction::make(), ]); } public static function getRelations(): array { return [ // ]; } public static function getPages(): array { return [ 'index' => Pages\ListApiProviders::route('/'), 'create' => Pages\CreateApiProvider::route('/create'), 'edit' => Pages\EditApiProvider::route('/{record}/edit'), ]; } protected static function getAvailablePlugins(): array { $plugins = []; $path = app_path('Api/Plugins'); $files = File::files($path); foreach ($files as $file) { $filename = $file->getFilenameWithoutExtension(); if (in_array($filename, ['ApiPluginInterface', 'PluginLoader'])) { continue; } $class = 'App\\Api\\Plugins\\' . $filename; if (class_exists($class) && in_array(ApiPluginInterface::class, class_implements($class))) { $instance = new $class(); $plugins[$instance->getIdentifier()] = $instance->getName(); } } return $plugins; } }