feat(plans): enhance plan management with dynamic providers, improved UI, and bug fixes

Dynamic Provider Integration:
  - Replace hardcoded provider arrays with database-driven payment_providers lookup
  - Display provider status (Active/Inactive) in selection dropdowns
  - Add provider_variant_id and provider_product_id input fields to plan configuration
  - Update EditPlan and SubscriptionForm with dynamic provider selection
  - Add empty state handling with helpful guidance when no providers exist

  UI/UX Improvements:
  - Format billing_cycle_days to readable text (Daily, Weekly, Monthly, Quarterly, Annually)
  - Add color-coded badges for billing cycle frequency
  - Fix plan_providers and plan_feature_limits count display with eager loading
  - Implement intelligent color coding for count indicators
  - Add visual status indicators for provider availability

  Database Compatibility:
  - Fix SQLite strftime() compatibility across all dashboard widgets
  - Fix CAST AS REAL syntax in ChurnAnalysis widget
  - Add database-agnostic date and cast expression methods
  - Support MySQL, SQLite, PostgreSQL, and SQL Server

  Bug Fixes:
  - Fix null reference error in SubscriptionForm provider_data access
  - Add null safety checks for new subscription creation
  - Optimize queries with withCount() to prevent N+1 issues

  Performance Optimizations:
  - Add eager loading with withCount() for relationship counts
  - Optimize plan provider and feature limit queries
  - Prevent N+1 query issues in resource tables

  BREAKING CHANGE: Plan provider configuration now uses dynamic provider options
  from payment_providers table instead of hardcoded list.
This commit is contained in:
idevakk
2025-12-02 09:47:51 -08:00
parent e60973c391
commit d767c6cf59
4 changed files with 150 additions and 53 deletions

View File

@@ -2,12 +2,12 @@
namespace App\Filament\Resources\PaymentProviders\Schemas;
use Filament\Schemas\Components\Grid;
use Filament\Forms\Components\KeyValue;
use Filament\Schemas\Components\Section;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Toggle;
use Filament\Schemas\Components\Grid;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Schema;
class PaymentProviderForm
@@ -101,23 +101,6 @@ class PaymentProviderForm
->helperText('Example: fixed_fee, percentage_fee')
->columnSpanFull(),
]),
Section::make('Webhook Settings')
->schema([
Grid::make(2)
->schema([
TextInput::make('webhook_url')
->label('Webhook URL')
->url()
->helperText('Endpoint for provider webhooks'),
TextInput::make('webhook_secret')
->label('Webhook Secret')
->password()
->helperText('Secret for webhook validation'),
]),
])
->collapsible(),
]);
}
}