<?php

namespace App\Models;

use App\Models\Concerns\BelongsToTenant;
use Illuminate\Database\Eloquent\Model;

class SmtpConfig extends Model
{
    use BelongsToTenant;

    protected $fillable = [
        'user_id', 'provider', 'name', 'host', 'port', 'encryption',
        'auto_tls', 'auth_enabled', 'username', 'password',
        'from_email', 'from_name', 'force_from_email', 'force_from_name',
        'return_path_match', 'max_per_hour', 'settings', 'oauth_token',
        'is_default', 'last_tested_at', 'last_test_status',
    ];

    protected $casts = [
        'password'          => 'encrypted',
        'settings'          => 'array',
        'oauth_token'       => 'encrypted:array',
        'is_default'        => 'boolean',
        'auto_tls'          => 'boolean',
        'auth_enabled'      => 'boolean',
        'force_from_email'  => 'boolean',
        'force_from_name'   => 'boolean',
        'return_path_match' => 'boolean',
        'last_tested_at'    => 'datetime',
        'port'              => 'integer',
        'max_per_hour'      => 'integer',
    ];

    protected $hidden = ['password', 'oauth_token'];
}
