schema([ Select::make('package_id') ->label('Paket') ->relationship('package', 'name') ->searchable() ->preload() ->required(), DateTimePicker::make('expires_at') ->label('Ablaufdatum') ->required(), TextInput::make('paddle_subscription_id') ->label('Paddle Subscription ID') ->maxLength(191) ->helperText('Abonnement-ID aus Paddle Billing.') ->nullable(), Toggle::make('active') ->label('Aktiv'), Textarea::make('reason') ->label('Grund') ->maxLength(65535) ->columnSpanFull(), ]) ->columns(2); } public function table(Table $table): Table { return $table ->recordTitleAttribute('package.name') ->columns([ TextColumn::make('package.name') ->label('Paket') ->badge() ->color('success'), TextColumn::make('used_events') ->label('Genutzte Events') ->badge(), TextColumn::make('remaining_events') ->label('Verbleibende Events') ->badge() ->color(fn ($state) => $state < 1 ? 'danger' : 'success') ->getStateUsing(fn ($record) => $record->remaining_events), TextColumn::make('expires_at') ->dateTime() ->sortable(), TextColumn::make('paddle_subscription_id') ->label('Paddle Subscription') ->toggleable(isToggledHiddenByDefault: true) ->formatStateUsing(fn ($state) => $state ?: '-'), IconColumn::make('active') ->boolean() ->color(fn (bool $state): string => $state ? 'success' : 'danger'), TextColumn::make('created_at') ->dateTime() ->sortable(), ]) ->filters([ SelectFilter::make('active') ->options([ '1' => 'Aktiv', '0' => 'Inaktiv', ]), ]) ->headerActions([]) ->actions([ EditAction::make(), Action::make('activate') ->label('Aktivieren') ->icon('heroicon-o-check-circle') ->color('success') ->action(fn ($record) => $record->update(['active' => true])), Action::make('deactivate') ->label('Deaktivieren') ->icon('heroicon-o-x-circle') ->color('danger') ->requiresConfirmation() ->action(fn ($record) => $record->update(['active' => false])), ]) ->bulkActions([ BulkActionGroup::make([ DeleteBulkAction::make(), ]), ]); } }