<?php

namespace Modules\ClinicCore\Entities;

use Illuminate\Database\Eloquent\Model;

/**
 * Item 3.1 - per-business knobs for the auto-block policy.
 */
class ClcBlockSetting extends Model
{
    protected $table = 'clc_block_settings';
    protected $guarded = ['id'];

    protected $casts = [
        'enable_auto_block'        => 'boolean',
        'block_zero_credit_limit'  => 'boolean',
    ];

    /** Lazily create the settings row on first read with sensible defaults. */
    public static function forBusiness(int $businessId): self
    {
        return static::firstOrCreate(['business_id' => $businessId]);
    }
}
