<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class SmsConfiguration extends Model
{
    protected $fillable = [
        'provider',
        'api_key',
        'api_secret',
        'sender_id',
        'config',
        'is_active',
    ];

    protected $hidden = [
        'api_key',
        'api_secret',
    ];

    protected function casts(): array
    {
        return [
            'config' => 'array',
            'is_active' => 'boolean',
        ];
    }

    /**
     * Get active SMS configuration (singleton)
     */
    public static function getActive(): ?self
    {
        return static::where('is_active', true)->first();
    }
}
