# Booking Reminder System - Complete Guide
## 🎯 Overview
The booking reminder system automatically sends notifications to customers before their upcoming reservations. The system is fully configurable through database settings and supports multiple reminder periods.
## 🏗️ System Architecture
### Components
1. **BookingReminderNotification** - Notification class with modern email template
2. **SendBookingReminders** - Console command for manual execution
3. **SendBookingRemindersJob** - Background job that processes reminders
4. **Console Scheduler** - Automatic hourly execution
### Flow
```
Scheduler (hourly) → Console Command → Background Job → Notification System → Customer
```
## ⚙️ Configuration
### Default Settings
The system sends reminders at:
- **72 hours** (3 days) before booking
- **24 hours** (1 day) before booking
### Custom Configuration
Add settings in your database `settings` table:
```sql
INSERT INTO settings (group, key, value) VALUES
('notifications', 'booking_reminder_periods', '[72, 24, 48]');
```
#### Available Periods (in hours)
- `168` = 7 days before
- `72` = 3 days before
- `48` = 2 days before
- `24` = 1 day before
- `12` = 12 hours before
- `6` = 6 hours before
## 🚀 Usage
### Automatic Execution (Recommended)
The system runs automatically every hour via Laravel scheduler:
```bash
# Make sure scheduler is running on your server
* * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1
```
### Manual Execution
#### Standard Run
```bash
php artisan bookings:send-reminders
```
#### Custom Periods
```bash
# Send 48-hour and 24-hour reminders only
php artisan bookings:send-reminders --periods=48,24
```
#### Dry Run (Testing)
```bash
# See what would be sent without actually sending
php artisan bookings:send-reminders --dry-run
```
#### Force Mode
```bash
# Send reminders regardless of timing (useful for testing)
php artisan bookings:send-reminders --force
```
#### Combined Options
```bash
# Test custom periods without sending
php artisan bookings:send-reminders --periods=12,6 --dry-run
```
## 📧 Email Template Features
### Modern Design
- **Dark Header** with countdown timer and booking pill
- **Hero Image** with venue fallback
- **Quick Actions** for viewing details and navigation
- **Visit Details** in clean key-value format
- **Helpful Tips** section with arrival guidance
- **Contact Information** for direct venue communication
- **Cancellation Policy** with clear deadlines
- **Mobile Responsive** design
### Dynamic Content
- **Hours Countdown**: Shows actual time remaining
- **PIN Codes**: Secure access codes for bookings
- **Map Links**: One-click Google Maps navigation
- **Venue Contact**: Direct phone/email/message links
- **Cancellation Deadlines**: Automatic calculation based on policy
## 🔧 Advanced Configuration
### Per-User Preferences
Users can disable reminders through notification preferences:
```php
// User notification preferences
$user->notificationPreferences = [
'email_reminders' => false, // Disable all email reminders
'sms_reminders' => true, // Keep SMS reminders
];
```
### Per-Venue Settings (Future Enhancement)
You can extend the system to support venue-specific reminder periods:
```php
// In venue model
public function getReminderPeriods(): array
{
return $this->reminder_periods ??
setting('booking_reminder_periods', 'notifications', [72, 24]);
}
```
## 📊 Monitoring & Logging
### Log Entries
The system logs all reminder activities:
```php
// Success
Log::info('Booking reminder sent', [
'booking_id' => 123,
'user_email' => 'customer@example.com',
'period_hours' => 24,
'hours_left' => 23.5
]);
// Errors
Log::error('Booking reminder failed', [
'booking_id' => 123,
'error' => 'SMTP connection failed'
]);
```
### Monitoring Commands
```bash
# Check recent reminder logs
grep "Booking reminder" storage/logs/laravel.log | tail -20
# Monitor job failures
grep "SendBookingRemindersJob" storage/logs/laravel.log | grep ERROR
```
## 🛠️ Troubleshooting
### Common Issues
#### 1. Reminders Not Sending
```bash
# Check if scheduler is running
php artisan schedule:run --dry-run
# Manually test the system
php artisan bookings:send-reminders --dry-run
```
#### 2. Wrong Timing
```bash
# Test with custom periods
php artisan bookings:send-reminders --periods=72,24 --dry-run
# Check booking dates and times
php artisan tinker
>>> $booking = App\Models\Booking::find(1);
>>> $booking->date;
>>> $booking->time_from;
>>> App\Notifications\BookingReminderNotification::calculateHoursLeft($booking);
```
#### 3. Duplicate Reminders
The system prevents duplicates by checking:
- Same period already sent in last 2 hours
- Booking status must be 'confirmed'
- Booking must be in the future
### Debug Mode
```bash
# Enable detailed logging
php artisan bookings:send-reminders --dry-run --force
```
## 📈 Performance Optimization
### Queue Configuration
```php
// config/queue.php
'connections' => [
'redis' => [
'driver' => 'redis',
'connection' => 'default',
'queue' => 'reminders',
// ...
],
],
```
### Job Optimization
- **Timeout**: 5 minutes per job
- **Retries**: 3 attempts on failure
- **Memory**: Efficient filtering to prevent memory issues
- **Batching**: Processes bookings in batches for large datasets
## 🔐 Security Features
### PIN Code Generation
- **6-digit random codes**
- **Unique per booking**
- **Stored securely in database**
- **Included in all reminder communications**
### Data Protection
- **No sensitive data in logs**
- **User preferences respected**
- **Opt-out functionality available**
- **GDPR compliant**
## 🎨 Customization
### Email Template Customization
Edit `resources/views/emails/booking-reminder.blade.php` to:
- Change colors and styling
- Add venue-specific information
- Include special offers or promotions
- Modify layout and structure
### Notification Content
Customize messages in `BookingReminderNotification.php`:
- SMS message templates
- Email subject lines
- Cancellation policy text
- Support contact information
## 📱 Multi-Channel Support
### Email
- Modern HTML template
- Responsive design
- Rich media support
- Action buttons
### SMS (GatewayAPI)
- Short, concise messages
- Essential information only
- PIN code included
- Booking reference
### Database
- Complete audit trail
- User notification history
- Admin dashboard integration
- Analytics and reporting
## 🔄 Integration Points
### Booking Creation
```php
// When booking is created
$booking->user->notify(new BookingConfirmedNotification(
$booking->user,
$booking,
$pinCode
));
```
### Booking Modification
```php
// When booking is modified
// Reminder system automatically adjusts timing
```
### Cancellation
```php
// When booking is cancelled
$booking->user->notify(new BookingCancellationNotification(
$booking,
$refundAmount,
$refundMethod
));
```
## 📋 Best Practices
### 1. Regular Monitoring
- Check logs daily for failures
- Monitor delivery rates
- Track user engagement
### 2. Settings Management
- Review reminder periods quarterly
- Adjust based on customer feedback
- Test new periods before deployment
### 3. Performance
- Monitor queue processing times
- Optimize database queries
- Use caching for frequently accessed data
### 4. User Experience
- Keep messages concise and helpful
- Provide clear action items
- Respect user preferences
- Test on mobile devices
## 🎉 Success Metrics
### Key Performance Indicators
- **Delivery Rate**: >95% of reminders delivered
- **Open Rate**: >60% of emails opened
- **Click Rate**: >15% of links clicked
- **Cancellation Reduction**: 20% fewer no-shows
### Analytics
```sql
-- Reminder effectiveness
SELECT
DATE(created_at) as date,
COUNT(*) as reminders_sent,
SUM(CASE WHEN status = 'completed' THEN 1 ELSE 0 END) as attended
FROM notifications
WHERE type = 'App\Notifications\BookingReminderNotification'
GROUP BY DATE(created_at);
```
This comprehensive system ensures customers never forget their bookings while providing a professional, modern experience that reflects well on your brand.