# Event Handling

Curtain emits various events that you can listen to for custom functionality. Let's see how to work with these events:

```php
namespace App\Providers;

use Illuminate\Support\Facades\Event;
use Daycode\Curtain\Events\MaintenanceModeEnabled;
use Daycode\Curtain\Events\MaintenanceModeDisabled;

class EventServiceProvider extends ServiceProvider
{
    public function boot()
    {
        // Listen for maintenance mode activation
        Event::listen(MaintenanceModeEnabled::class, function ($event) {
            // For example, notify your team on Slack
            Notification::route('slack', 'webhook-url')
                ->notify(new MaintenanceModeNotification($event));
            
            // Or log to monitoring service
            Log::channel('monitoring')->info('Maintenance mode activated', [
                'duration' => $event->duration,
                'message' => $event->message
            ]);
        });

        // Listen for maintenance mode deactivation
        Event::listen(MaintenanceModeDisabled::class, function ($event) {
            // Perform cleanup tasks
            Cache::tags(['maintenance'])->flush();
            
            // Notify team
            Mail::to('team@example.com')->send(new MaintenanceCompletedMail());
        });
    }
}
```
