components([ Section::make('Plan Information') ->description('Add a new plan') ->schema([ TextInput::make('name')->label('Page Name') ->required(), TextInput::make('description'), TextInput::make('product_id')->required(), TextInput::make('pricing_id')->required(), TextInput::make('shoppy_product_id')->nullable(), TextInput::make('oxapay_link')->nullable(), TextInput::make('price')->numeric()->required(), TextInput::make('mailbox_limit')->numeric()->required(), Select::make('monthly_billing')->options([ 1 => 'Monthly', 0 => 'Yearly', ])->required(), Select::make('accept_stripe')->options([ 1 => 'Activate', 0 => 'Disable', ])->required(), Select::make('accept_shoppy')->options([ 1 => 'Activate', 0 => 'Disable', ])->required(), Select::make('accept_oxapay')->options([ 1 => 'Activate', 0 => 'Disable', ])->required(), KeyValue::make('details') ->label('Plan Details (Optional)') ->keyPlaceholder('Name') ->valuePlaceholder('Content') ->reorderable(), ]), ]); } public static function table(Table $table): Table { return $table ->columns([ TextColumn::make('name')->label('Name')->searchable(), TextColumn::make('product_id')->label('Product'), TextColumn::make('pricing_id')->label('Pricing'), TextColumn::make('price')->label('Price'), BooleanColumn::make('monthly_billing')->label('Monthly Billing'), ]) ->searchable() ->filters([ SelectFilter::make('payment_method') ->label('Payment Method') ->options([ 'stripe' => 'Stripe', 'shoppy' => 'Shoppy', 'oxapay' => 'OxaPay', ]) ->query(function ($query, array $data) { if (isset($data['value'])) { if ($data['value'] === 'stripe') { return $query->where('accept_stripe', true); } if ($data['value'] === 'shoppy') { return $query->where('accept_shoppy', true); } if ($data['value'] === 'oxapay') { return $query->where('accept_oxapay', true); } } return $query; }), ]) ->recordActions([ ViewAction::make(), EditAction::make(), DeleteAction::make(), ]) ->toolbarActions([ BulkActionGroup::make([ DeleteBulkAction::make(), ]), ]); } public static function getRelations(): array { return [ // ]; } public static function getPages(): array { return [ 'index' => ListPlans::route('/'), 'create' => CreatePlan::route('/create'), 'edit' => EditPlan::route('/{record}/edit'), ]; } }