# SMS Configuration Module

## Overview

This module provides a complete SMS configuration system for integrating with Africa's Talking API. It allows Super Managers to configure API credentials, test connections, and provides a reusable SMSService for other modules to send SMS messages.

## Features

- **Credential Management**: Secure storage of Africa's Talking API credentials with encryption
- **Connection Testing**: Test SMS functionality before going live
- **SMS Logging**: Complete audit trail of all SMS messages
- **Reusable Service**: Simple API for other modules to send SMS
- **Role-Based Access**: Only Super Managers can manage configuration
- **Developer Documentation**: Built-in integration guide

## File Structure

```
sms-module/
├── app/
│   ├── Http/
│   │   ├── Controllers/
│   │   │   └── SmsConfigurationController.php
│   │   └── Requests/
│   │       ├── SmsConfigurationRequest.php
│   │       └── SmsTestRequest.php
│   ├── Models/
│   │   ├── SmsConfiguration.php
│   │   └── SmsLog.php
│   └── Services/
│       ├── ConfigurationService.php
│       ├── SMSProvider.php
│       └── SMSService.php
├── database/
│   ├── migrations/
│   │   ├── 2024_01_01_000001_create_sms_configurations_table.php
│   │   └── 2024_01_01_000002_create_sms_logs_table.php
│   └── seeders/
│       └── SmsPermissionSeeder.php
├── resources/
│   └── views/
│       └── config/
│           └── sms/
│               ├── index.blade.php
│               ├── form.blade.php
│               ├── logs.blade.php
│               └── documentation.blade.php
├── routes/
│   └── sms.php
├── DEPENDENCIES.md
└── README.md
```

## Quick Start

### 1. Copy Files

Copy all files to your Laravel project maintaining the directory structure.

### 2. Run Migrations

```bash
php artisan migrate
```

### 3. Seed Permissions

```bash
php artisan db:seed --class=SmsPermissionSeeder
```

### 4. Include Routes

Add to your `routes/web.php`:

```php
require __DIR__ . '/sms.php';
```

### 5. Access the Module

Navigate to `/config/sms` as a Super Manager user.

## Using SMSService in Your Code

```php
use App\Services\SMSService;

// Method 1: Dependency Injection
public function sendNotification(SMSService $smsService)
{
    $result = $smsService->send('+254712345678', 'Hello!');
    
    if ($result['success']) {
        // SMS sent successfully
    }
}

// Method 2: App Helper
$result = app(SMSService::class)->send('+254712345678', 'Hello!');
```

## Documentation

For complete integration documentation, see the `DEPENDENCIES.md` file or visit `/config/sms/documentation` after installation.

## Requirements

- Laravel 12.x
- PHP 8.2 or 8.3
- MySQL 5.7+
- Spatie Laravel Permission package

## License

This module is part of the SSHIA Laravel System.
