<?php

namespace App\Models\Synapse;

use App\Models\Solicitor\Solicitor;
use App\Models\User;
use App\Trait\BelongsToSolicitor;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\MorphTo;

class SynapseRun extends Model {
    protected $fillable = [
        'solicitor_id',
        'user_id',
        'agent_type',
        'subject_type',
        'subject_id',
        'status',
        'error',
        'result',
    ];

    protected $casts = [
        'result' => 'array',
    ];

    use BelongsToSolicitor;

    public function solicitor(): BelongsTo {
        return $this->belongsTo(Solicitor::class);
    }

    public function user(): BelongsTo {
        return $this->belongsTo(User::class);
    }

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