<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class ComplianceRule extends Model
{
    use HasFactory;

    protected $fillable = [
        'company_id',
        'rule_name',
        'rule_type',
        'description',
        'rule_config',
        'severity',
        'is_active',
        'is_group_level',
    ];

    protected $casts = [
        'rule_config' => 'array',
        'is_active' => 'boolean',
        'is_group_level' => 'boolean',
    ];

    public function company()
    {
        return $this->belongsTo(Company::class);
    }

    public function alerts()
    {
        return $this->hasMany(ComplianceAlert::class, 'compliance_rule_id');
    }
}
