components([ Section::make('Basic Information') ->schema([ Grid::make(2) ->schema([ Select::make('user_id') ->label('User') ->relationship('user', 'name') ->searchable() ->preload() ->required() ->createOptionForm([ TextInput::make('name') ->required(), TextInput::make('email') ->email() ->required(), ]), Select::make('plan_id') ->label('Plan') ->relationship('plan', 'name') ->searchable() ->preload() ->required(), ]), Grid::make(2) ->schema([ Select::make('type') ->label('Subscription Type') ->options([ 'default' => 'Default', 'premium' => 'Premium', 'enterprise' => 'Enterprise', 'trial' => 'Trial', ]) ->required() ->default('default') ->helperText('Type of subscription'), Select::make('status') ->label('Status') ->options([ 'active' => 'Active', 'trialing' => 'Trial', 'cancelled' => 'Cancelled', 'paused' => 'Paused', 'incomplete' => 'Incomplete', ]) ->required() ->default('active'), ]), Grid::make(2) ->schema([ Select::make('provider') ->label('Provider') ->options([ 'stripe' => 'Stripe', 'lemon_squeezy' => 'Lemon Squeezy', 'polar' => 'Polar.sh', 'oxapay' => 'OxaPay', 'crypto' => 'Crypto', 'activation_key' => 'Activation Key', ]) ->required() ->default('stripe'), TextInput::make('provider_subscription_id') ->label('Provider Subscription ID'), ]), ]), Section::make('Trial Management') ->schema([ Grid::make(2) ->schema([ DateTimePicker::make('trial_ends_at') ->label('Trial Ends At'), TextInput::make('quantity') ->label('Quantity') ->numeric() ->default(1), ]), ]) ->collapsible(), Section::make('Billing Dates') ->schema([ Grid::make(2) ->schema([ DateTimePicker::make('starts_at') ->label('Starts At'), DateTimePicker::make('ends_at') ->label('Ends At'), ]), Grid::make(2) ->schema([ DateTimePicker::make('cancelled_at') ->label('Cancelled At'), DateTimePicker::make('paused_at') ->label('Paused At'), ]), Grid::make(2) ->schema([ DateTimePicker::make('resumed_at') ->label('Resumed At'), DateTimePicker::make('last_provider_sync') ->label('Last Provider Sync'), ]), ]) ->collapsible(), Section::make('Cancellation Details') ->schema([ Textarea::make('cancellation_reason') ->label('Reason'), ]) ->collapsible() ->visible(fn ($get) => $get('status') === 'cancelled'), Section::make('Provider Information') ->schema([ TextInput::make('stripe_id') ->label('Stripe ID') ->visible(fn ($get) => $get('provider') === 'stripe'), TextInput::make('stripe_status') ->label('Stripe Status') ->visible(fn ($get) => $get('provider') === 'stripe'), TextInput::make('stripe_price') ->label('Stripe Price') ->visible(fn ($get) => $get('provider') === 'stripe'), Textarea::make('provider_data') ->label('Provider Data') ->rows(3) ->helperText('JSON data from the payment provider'), ]) ->collapsible(), Section::make('Migration Information') ->schema([ TextInput::make('migration_batch_id') ->label('Migration Batch ID'), Toggle::make('is_migrated') ->label('Is Migrated'), Textarea::make('legacy_data') ->label('Legacy Data') ->rows(3), ]) ->collapsible(), ]); } }