components([ TextInput::make('name') ->required() ->maxLength(255), Toggle::make('enabled') ->default(true), TextInput::make('api_url') ->required() ->url() ->maxLength(255), TextInput::make('username') ->nullable() ->maxLength(255), TextInput::make('password') ->password() ->nullable() ->maxLength(255), TextInput::make('token') ->nullable() ->maxLength(255), Select::make('plugin') ->options($plugins) ->nullable(), ]); } public static function table(Table $table): Table { return $table ->columns([ TextColumn::make('name')->searchable()->sortable(), IconColumn::make('enabled') ->boolean(), TextColumn::make('api_url')->searchable(), TextColumn::make('plugin')->searchable()->sortable(), ]) ->filters([ // ]) ->actions([ EditAction::make(), ]) ->bulkActions([ BulkActionGroup::make([ DeleteBulkAction::make(), ]), ]) ->emptyStateActions([ 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))) { $plugins[$filename] = $filename; } } return $plugins; } }