<?php

namespace App\Models;

use CodeIgniter\Model;

class NotificationSettingModel extends Model
{
    protected $table = 'notification_settings';
    protected $primaryKey = 'id';
    protected $useTimestamps = true;
    protected $allowedFields = ['company_id', 'renewal_days_before', 'invoice_due_days_before', 'admin_notification_email'];

    public function daysArray(?array $setting, string $field): array
    {
        if (! $setting || empty($setting[$field])) {
            return [15, 7, 3, 1];
        }
        return array_map('intval', explode(',', $setting[$field]));
    }
}
