# Database Settings Seeder - Usage Guide
## 🚀 Quick Start
### 1. Run the Migration
```bash
php artisan migrate
```
### 2. Run the Seeder
```bash
# Run only the notification settings seeder
php artisan db:seed --class=NotificationSettingsSeeder
# Or run all seeders (includes notification settings)
php artisan db:seed
```
## 📋 Seeded Settings
The seeder creates the following notification settings in your database:
### 🔄 Reminder Settings
- **`booking_reminder_periods`**: `[72, 24]` - Send reminders 3 days and 1 day before booking
### 📧 Email Settings
- **`enable_email_notifications`**: `true` - Global email toggle
- **`from_email`**: `notifications@zapazime.bg` - From email address
- **`from_name`**: `ZapaziMe.bg` - From display name
### 📱 SMS Settings
- **`enable_sms_notifications`**: `true` - Global SMS toggle
- **`sms_from_number`**: `ZapaziMe` - SMS sender ID
### 🔔 Notification Types
- **`send_booking_confirmation`**: `true` - Send booking confirmations
- **`booking_confirmation_channels`**: `["mail", "database"]` - Channels for confirmations
- **`send_booking_cancellation`**: `true` - Send cancellation notices
- **`booking_cancellation_channels`**: `["mail", "database"]` - Channels for cancellations
- **`send_account_updates`**: `true` - Send account updates
- **`account_update_channels`**: `["mail", "database"]` - Channels for account updates
### 👤 Default User Preferences
- **`default_email_reminders`**: `true` - New users get email reminders
- **`default_sms_reminders`**: `true` - New users get SMS reminders
- **`default_marketing_emails`**: `false` - New users don't get marketing emails
### 📞 Contact Information
- **`contact_email`**: `support@zapazime.bg` - Support email
- **`support_phone`**: `+359 888 123 456` - Support phone
### ⚡ Performance Settings
- **`rate_limit_emails`**: `10` - Max emails per hour per user
- **`rate_limit_sms`**: `5` - Max SMS per hour per user
- **`queue_connection`**: `redis` - Queue connection for notifications
- **`queue_name`**: `notifications` - Queue name for notifications
## 🛠️ Customizing Settings
### Method 1: Update Database Directly
```sql
-- Change reminder periods to 7 days, 2 days, and 12 hours
UPDATE settings
SET value = '[168, 48, 12]'
WHERE group = 'notifications' AND key = 'booking_reminder_periods';
-- Disable SMS notifications globally
UPDATE settings
SET value = 'false'
WHERE group = 'notifications' AND key = 'enable_sms_notifications';
```
### Method 2: Update Seeder and Re-run
1. Edit `database/seeders/NotificationSettingsSeeder.php`
2. Modify the values in the `$settings` array
3. Run: `php artisan db:seed --class=NotificationSettingsSeeder`
### Method 3: Use Laravel Tinker
```bash
php artisan tinker
>>> DB::table('settings')
... ->where('group', 'notifications')
... ->where('key', 'booking_reminder_periods')
... ->update(['value' => json_encode([48, 24, 12])]);
```
## 🔍 Verifying Settings
### Check All Settings
```bash
php artisan tinker
>>> DB::table('settings')->where('group', 'notifications')->get();
```
### Check Specific Setting
```bash
php artisan tinker
>>> setting('booking_reminder_periods', 'notifications');
```
### Test Helper Functions
```bash
php artisan tinker
>>> use App\Helpers\NotificationSettingsHelper;
>>> NotificationSettingsHelper::getReminderPeriods();
>>> NotificationSettingsHelper::getContactEmail();
>>> NotificationSettingsHelper::getDefaultUserPreferences();
```
## 🎯 Common Customizations
### Add More Reminder Periods
```sql
-- Send reminders at 7 days, 3 days, 2 days, 1 day, and 12 hours
UPDATE settings
SET value = '[168, 72, 48, 24, 12]'
WHERE group = 'notifications' AND key = 'booking_reminder_periods';
```
### Enable SMS for All Notifications
```sql
UPDATE settings
SET value = '["mail", "database", "gatewayapi"]'
WHERE group = 'notifications'
AND key IN ('booking_confirmation_channels', 'booking_cancellation_channels', 'account_update_channels');
```
### Change Contact Information
```sql
UPDATE settings
SET value = 'your-support@example.com'
WHERE group = 'notifications' AND key = 'contact_email';
UPDATE settings
SET value = '+359 888 999 888'
WHERE group = 'notifications' AND key = 'support_phone';
```
## 🔄 After Changing Settings
### 1. Clear Cache
```bash
php artisan cache:clear
php artisan config:clear
```
### 2. Test Reminder System
```bash
# Dry run to test new settings
php artisan bookings:send-reminders --dry-run
# Test specific periods
php artisan bookings:send-reminders --periods=48,24 --dry-run
```
### 3. Monitor Logs
```bash
tail -f storage/logs/laravel.log | grep "Booking reminder"
```
## 📊 Settings Schema
The settings table structure:
```sql
CREATE TABLE settings (
id BIGINT PRIMARY KEY AUTO_INCREMENT,
group VARCHAR(50) INDEX, -- 'notifications'
key VARCHAR(100) INDEX, -- 'booking_reminder_periods'
value LONGTEXT, -- '[72, 24]'
type VARCHAR(20) DEFAULT 'string', -- 'array', 'boolean', 'integer'
description TEXT, -- Human-readable description
is_public BOOLEAN DEFAULT FALSE, -- API accessibility
created_at TIMESTAMP,
updated_at TIMESTAMP,
UNIQUE KEY unique_group_key (group, key)
);
```
## 🚨 Important Notes
1. **Backup First**: Always backup your database before running seeders
2. **Environment**: Settings work in all environments (local, staging, production)
3. **Caching**: Some settings may be cached, clear cache after changes
4. **Validation**: The seeder includes validation for setting types and values
5. **Dependencies**: The reminder system requires these settings to function properly
## 🎉 Success Indicators
After running the seeder successfully, you should see:
- ✅ "Notification settings seeded successfully!" message
- ✅ List of all seeded settings with their values
- ✅ Settings visible in database `settings` table
- ✅ Reminder system working with configured periods
Your notification system is now fully configured and ready to use! 🎉