Booking Update Notification System - Complete Guide

📄 General
← Back to Documentation
# Booking Update Notification System - Complete Guide ## 🎯 Overview The booking update notification system provides comprehensive notifications when booking details are modified. It features a modern email template with before/after comparisons, multi-channel delivery, and full integration with the admin panel settings. ## 🏗️ System Architecture ### Components 1. **BookingUpdatedNotification** - Enhanced notification class 2. **booking-update.blade.php** - Modern email template 3. **Admin Panel Integration** - Channel configuration 4. **Multi-channel Support** - Email, SMS, Database, GatewayAPI ### Flow ``` Booking Update → Notification Class → Channel Selection → Template Rendering → Customer Delivery ``` ## 📧 Email Template Features ### Modern Design Elements - **Dark Green Header** with update indicator - **Venue Hero Image** with fallback support - **Before/After Comparison** with color-coded tags - **Change Summary** with update details - **Interactive Actions** - View booking, confirm changes - **Location Information** with map integration - **Policy Information** with cancellation details - **Support Links** and legal notices ### Dynamic Content Sections #### **1. Header Section** ```html ✏️ Промяна по резервацията ти {venue_name} • Номер: {booking_number} ``` #### **2. Change Summary** ```html Какво е променено {update_summary} Обновено от: {updated_by} • Време: {updated_at} ({timezone}) ``` #### **3. Before/After Comparison** ```html Преди Сега {old_date} {new_date} {old_time_from} {new_time_from} {old_quantity} {new_quantity} {old_service_name} {new_service_name} ``` #### **4. Location & Actions** ```html {venue_name} {venue_address_line_1} {venue_city}, {venue_postcode} [Show on Map] [View Booking] [Confirm Changes] ``` ## 🔧 Notification Class Features ### Enhanced Constructor ```php public function __construct( User $user, Booking $booking, string $updateSummary, string $updatedBy, array $oldValues = [], array $newValues = [], ?string $cancellationSummary = null ) ``` ### Template Variables ```php // Basic Information 'user', 'booking', 'venue' // Update Details 'update_summary', 'updated_by', 'updated_at', 'timezone' // Customer Information 'customer_name', 'customer_email' // Venue Details 'venue_name', 'venue_image_url', 'venue_address_line_1', 'venue_city', 'venue_postcode', 'venue_country' // Booking Details 'booking_number' // Before/After Values 'old_date', 'new_date', 'old_time_from', 'new_time_from', 'old_time_to', 'new_time_to', 'old_quantity', 'new_quantity', 'old_service_name', 'new_service_name' // Links & Policies 'view_booking_link', 'confirm_changes_link', 'map_link', 'policies_link', 'support_email', 'support_link', 'unsubscribe_link' ``` ### Channel Configuration ```php public function via(object $notifiable): array { $channels = NotificationSettingsHelper::getNotificationChannels('booking_update'); return NotificationSettingsHelper::getAvailableChannels($notifiable, $channels); } ``` ## 📱 Multi-Channel Support ### Email (Primary) - **Modern HTML template** with responsive design - **Before/After comparison** with visual indicators - **Interactive buttons** for quick actions - **Rich media support** with venue images ### SMS (GatewayAPI) ```php // Bulgarian "Промяна по резервация #12345: Venue Name. Summary of changes. Виж: [link]" // English "Booking #12345 updated: Venue Name. Summary of changes. View: [link]" ``` ### Database (In-App) - **Complete audit trail** of all updates - **Structured data** for admin dashboard - **Change tracking** with old/new values ## ⚙️ Configuration ### Admin Panel Settings 1. **Navigate to**: Settings → Notification Settings → Booking Notifications 2. **Configure**: Booking Update Channels 3. **Options**: Email, SMS, In-App, GatewayAPI ### Channel Selection ``` ☑ Email - Primary delivery with full details ☐ SMS - Brief notification with link ☑ In-App - Dashboard notification ☐ GatewayAPI - SMS alternative ``` ## 🚀 Usage Examples ### Basic Booking Update ```php $user->notify(new BookingUpdatedNotification( $user, $booking, 'Дата и час на резервацията са променени', 'Admin User', [ 'date' => '15.03.2024', 'time_from' => '14:00', 'time_to' => '16:00' ], [ 'date' => '16.03.2024', 'time_from' => '15:00', 'time_to' => '17:00' ] )); ``` ### Service Change Update ```php $user->notify(new BookingUpdatedNotification( $user, $booking, 'Променена услуга от "Масаж" на "Физиотерапия"', 'System', [ 'service_name' => 'Масаж', 'quantity' => 1 ], [ 'service_name' => 'Физиотерапия', 'quantity' => 2 ], 'Безплатна промяна до 24 часа преди резервация' )); ``` ### Quantity Update ```php $user->notify(new BookingUpdatedNotification( $user, $booking, 'Брой места е променен от 2 на 4', 'Customer Request', ['quantity' => 2], ['quantity' => 4] )); ``` ## 📊 Integration Points ### With Booking System ```php // In booking update controller public function update(Request $request, Booking $booking) { $oldValues = $booking->only(['date', 'time_from', 'time_to', 'quantity']); $booking->update($request->validated()); $newValues = $booking->only(['date', 'time_from', 'time_to', 'quantity']); $booking->user->notify(new BookingUpdatedNotification( $booking->user, $booking, $request->input('update_summary', 'Резервацията е обновена'), auth()->user()->name, $oldValues, $newValues )); } ``` ### With Admin Panel ```php // Admin modifies booking if ($adminMadeChanges) { $booking->user->notify(new BookingUpdatedNotification( $booking->user, $booking, 'Администратор направи промени по вашата резервация', auth()->user()->name, $oldValues, $newValues )); } ``` ### With Automated Systems ```php // System automatically reschedules due to availability $booking->user->notify(new BookingUpdatedNotification( $booking->user, $booking, 'Автоматично преместване поради технически причини', 'System', $oldValues, $newValues, 'Извиняваме се за неудобството. Промяната е безплатна.' )); ``` ## 🎨 Template Customization ### Color Scheme - **Header**: `#064e3b` (Dark Green) - **Primary Button**: `#2563eb` (Blue) - **Warning Button**: `#f59e0b` (Orange) - **New Tag**: `#dcfce7` (Light Green) - **Old Tag**: `#f3f4f6` (Gray) ### Responsive Design ```css @media (max-width: 620px) { .card { width:100% !important; border-radius:0 !important; } .p-24 { padding:18px !important; } .hide-mobile { display:none !important; } } ``` ### Custom Sections Add new sections by modifying the template: ```html <!-- Custom Section --> <table role="presentation" width="100%" cellpadding="0" cellspacing="0" class="box"> <tr> <td class="p-16"> <h2 class="h2">Custom Title</h2> <p class="text">{{ $custom_variable }}</p> </td> </tr> </table> ``` ## 📈 Performance & Optimization ### Efficient Data Loading ```php // Only load what's needed $this->venueImageUrl = $booking->venue->getFirstImageUrl() ?? asset('images/default-venue.jpg'); // Fallback values for missing data $this->oldQuantity = $oldValues['quantity'] ?? $booking->quantity ?? 1; ``` ### Channel Optimization ```php // Use configured channels $channels = NotificationSettingsHelper::getNotificationChannels('booking_update'); return NotificationSettingsHelper::getAvailableChannels($notifiable, $channels); ``` ### Queue Processing ```php class BookingUpdatedNotification implements ShouldQueue { use Queueable; // Automatically queued for background processing } ``` ## 🔍 Testing & Debugging ### Test Email Template ```bash # Create test booking update php artisan tinker >>> $booking = App\Models\Booking::find(1); >>> $user = $booking->user; >>> $user->notify(new App\Notifications\BookingUpdatedNotification( ... $user, $booking, 'Test update', 'Test User', ... ['date' => '01.01.2024'], ['date' => '02.01.2024'] ... )); ``` ### Test SMS Message ```bash # Test SMS delivery php artisan tinker >>> $notification = new App\Notifications\BookingUpdatedNotification(...); >>> $smsMessage = $notification->toGatewayApi($user); >>> echo $smsMessage->content; ``` ### Verify Database Storage ```bash # Check in-app notifications php artisan tinker >>> App\Models\Notification::latest()->first(); ``` ## 🚨 Best Practices ### Change Detection ```php // Only notify if actual changes occurred if ($booking->wasChanged()) { $changes = $booking->getChanges(); $oldValues = $booking->getOriginal(); $booking->user->notify(new BookingUpdatedNotification( $booking->user, $booking, $this->generateUpdateSummary($changes), auth()->user()->name, $oldValues, $changes )); } ``` ### User Preferences ```php // Respect user notification preferences if ($user->wantsNotification('booking_updates')) { $user->notify(new BookingUpdatedNotification(...)); } ``` ### Error Handling ```php try { $user->notify(new BookingUpdatedNotification(...)); } catch (\Exception $e) { Log::error('Booking update notification failed', [ 'booking_id' => $booking->id, 'error' => $e->getMessage() ]); } ``` ## 📋 Monitoring & Analytics ### Track Delivery Rates ```php // In notification class public function toArray(object $notifiable): array { return [ 'delivery_tracked' => true, 'notification_type' => 'booking_update', 'sent_at' => now()->toISOString(), // ... other tracking data ]; } ``` ### Monitor User Engagement ```php // Track click-through rates // Add UTM parameters to links 'view_booking_link' => route('bookings.show', $booking->id) . '?utm_source=email&utm_medium=booking_update'; ``` ## 🎉 Success Metrics ### Key Performance Indicators - **Open Rate**: >70% (high interest in changes) - **Click Rate**: >25% (users want to see details) - **Confirmation Rate**: >80% (users acknowledge changes) - **Support Reduction**: 30% fewer support calls about updates ### User Experience Benefits - **Transparency**: Clear before/after comparison - **Control**: Easy confirmation and management - **Clarity**: Detailed change summaries - **Convenience**: Direct links to relevant actions Your booking update notification system is now complete with modern design, comprehensive features, and full integration! 🎉 ## 🔄 Next Steps 1. **Test the system** with various update scenarios 2. **Configure channels** in admin panel 3. **Monitor delivery** and user engagement 4. **Gather feedback** and optimize template 5. **Scale to other notification types** using the same pattern