<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\MorphTo;

class AmlScreeningResult extends Model
{
    protected $fillable = [
        'screenable_type',
        'screenable_id',
        'risk_level',
        'match_status',
        'total_results',
        'total_articles',
        'results',
        'entity_id',
        'screened_by',
        'screened_at',
    ];

    protected function casts(): array
    {
        return [
            'results'     => 'array',
            'screened_at' => 'datetime',
        ];
    }

    public function screenable(): MorphTo
    {
        return $this->morphTo();
    }

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