<?php

namespace App\Models;

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

class JobAiAssistance extends Model
{
    public const TYPE_COVER_LETTER = 'cover_letter';

    public const TYPE_INTERVIEW_PREP = 'interview_prep';

    public const TYPE_MATCH_EXPLANATION = 'match_explanation';

    public const STATUS_COMPLETED = 'completed';

    public const STATUS_FAILED = 'failed';

    protected $fillable = [
        'user_id',
        'imported_job_id',
        'type',
        'status',
        'content',
        'payload',
        'failure_reason',
        'generated_at',
    ];

    /**
     * @return BelongsTo<User, $this>
     */
    public function user(): BelongsTo
    {
        return $this->belongsTo(User::class);
    }

    /**
     * @return BelongsTo<ImportedJob, $this>
     */
    public function importedJob(): BelongsTo
    {
        return $this->belongsTo(ImportedJob::class);
    }

    /**
     * @return array<string, string>
     */
    protected function casts(): array
    {
        return [
            'payload' => 'array',
            'generated_at' => 'datetime',
        ];
    }
}
