schema([ Forms\Components\TextInput::make('uuid')->label('UUID')->required()->maxLength(36), Forms\Components\Select::make('ride_id')->label('Trayecto')->relationship('ride', 'id')->default(null), Forms\Components\Select::make('offer_id')->label('Oferta')->relationship('offer', 'title')->required(), Forms\Components\TextInput::make('ride_recommendation_id')->label('Recomendación')->numeric()->default(null), Forms\Components\TextInput::make('customer_name')->label('Cliente')->maxLength(255)->default(null), Forms\Components\TextInput::make('customer_email')->email()->maxLength(255)->default(null), Forms\Components\TextInput::make('customer_phone')->tel()->maxLength(255)->default(null), Forms\Components\TextInput::make('party_size')->label('Personas')->required()->numeric()->default(1), Forms\Components\DateTimePicker::make('booking_for')->label('Fecha / hora'), Forms\Components\TextInput::make('status')->label('Estado')->required(), Forms\Components\TextInput::make('amount')->label('Importe')->numeric()->default(null), Forms\Components\TextInput::make('commission_amount')->label('Comisión')->numeric()->default(null), Forms\Components\Textarea::make('notes')->label('Nota')->columnSpanFull(), ]); } public static function table(Table $table): Table { return $table ->defaultSort('created_at', 'desc') ->columns([ Tables\Columns\TextColumn::make('offer.title') ->label('Oferta') ->searchable() ->weight('semibold'), Tables\Columns\TextColumn::make('customer_name') ->label('Cliente') ->searchable() ->description(fn (Booking $record): string => $record->ride?->pickup_label ? 'Ride: '.$record->ride->pickup_label : 'Reserva directa'), Tables\Columns\TextColumn::make('status') ->label('Estado') ->badge() ->color(fn (?string $state): string => match ($state) { 'confirmed', 'completed' => 'success', 'pending' => 'warning', 'cancelled' => 'danger', default => 'gray', }), Tables\Columns\TextColumn::make('amount') ->label('Importe') ->money('EUR') ->sortable(), Tables\Columns\TextColumn::make('commission_amount') ->label('Comisión') ->money('EUR') ->sortable(), Tables\Columns\TextColumn::make('ride_recommendation_id') ->label('Top') ->formatStateUsing(fn ($state): string => $state ? 'Sí' : 'Directa') ->badge() ->color(fn ($state): string => $state ? 'primary' : 'gray'), Tables\Columns\TextColumn::make('booking_for') ->label('Fecha') ->dateTime('d/m/Y H:i') ->sortable() ->toggleable(), Tables\Columns\TextColumn::make('created_at') ->label('Creada') ->since() ->sortable(), Tables\Columns\TextColumn::make('uuid') ->label('UUID') ->copyable() ->toggleable(isToggledHiddenByDefault: true), ]) ->actions([ Tables\Actions\EditAction::make(), ]) ->bulkActions([ Tables\Actions\BulkActionGroup::make([ Tables\Actions\DeleteBulkAction::make(), ]), ]); } public static function getRelations(): array { return []; } public static function getPages(): array { return [ 'index' => Pages\ListBookings::route('/'), 'create' => Pages\CreateBooking::route('/create'), 'edit' => Pages\EditBooking::route('/{record}/edit'), ]; } }