<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;

class InactivityFeeRun extends Model
{
    use HasFactory;

    protected $guarded = [];

    protected $casts = [
        'settings_json' => 'array',
        'preview_json' => 'array',
        'result_json' => 'array',
        'started_at' => 'datetime',
        'completed_at' => 'datetime',
    ];

    public function initiatedByAdmin(): BelongsTo
    {
        return $this->belongsTo(User::class, 'initiated_by_admin_id');
    }

    public function charges(): HasMany
    {
        return $this->hasMany(InactivityFeeCharge::class, 'run_id');
    }
}
