<?php

namespace App\Models;

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

class QuestionnaireResponse extends Model
{
    /** @use HasFactory<QuestionnaireResponseFactory> */
    use HasFactory;

    /**
     * The attributes that are mass assignable.
     *
     * @var list<string>
     */
    protected $fillable = [
        'user_id',
        'answers',
        'preferred_categories',
        'preferred_roles',
        'skills',
        'experience_level',
        'availability',
        'preferred_timezone',
        'country_code',
        'salary_currency',
        'salary_min',
        'open_to_contract',
        'open_to_full_time',
        'completed_at',
    ];

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

    /**
     * Get the attributes that should be cast.
     *
     * @return array<string, string>
     */
    protected function casts(): array
    {
        return [
            'answers' => 'array',
            'preferred_categories' => 'array',
            'preferred_roles' => 'array',
            'skills' => 'array',
            'salary_min' => 'integer',
            'open_to_contract' => 'boolean',
            'open_to_full_time' => 'boolean',
            'completed_at' => 'datetime',
        ];
    }
}
