<?php

namespace App\Models;

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

class ArchiveSetting extends Model
{
    use HasFactory;
    use SoftDeletes;

    protected $fillable = [
        'action_id',
        'decision_id',
        'segment_id',
        'entities',
        'name',
        'description',
        'enabled',
        'strategy',
        'soft',
        'reactivate',
        'options',
        'created_by',
        'updated_by',
    ];

    protected function casts(): array
    {
        return [
            'entities' => 'array',
            'options' => 'array',
            'enabled' => 'boolean',
            'soft' => 'boolean',
            'reactivate' => 'boolean',
        ];
    }

    // Relationships (nullable FKs)
    public function action()
    {
        return $this->belongsTo(Action::class);
    }

    public function decision()
    {
        return $this->belongsTo(Decision::class);
    }

    public function segment()
    {
        return $this->belongsTo(Segment::class);
    }

    public function creator()
    {
        return $this->belongsTo(User::class, 'created_by');
    }

    public function updater()
    {
        return $this->belongsTo(User::class, 'updated_by');
    }
}
