<?php

namespace App\Models;

use App\Entities\CandidateProfile;
use CodeIgniter\Model;

class CandidateProfileModel extends Model
{
    protected $table         = 'candidate_profiles';
    protected $primaryKey    = 'id';
    protected $returnType    = CandidateProfile::class;
    protected $useTimestamps = true;
    protected $allowedFields = [
        'user_id', 'profile_picture_path', 'cover_letter', 'headline', 'about', 'video_intro_url',
        'salary_expectation_min', 'salary_expectation_max', 'current_salary', 'salary_currency',
        'preferred_locations', 'work_preference', 'preferred_employment_type', 'career_level',
        'industry_preferences', 'availability_status', 'notice_period_end',
        'is_public', 'hide_email', 'hide_mobile', 'hide_employer', 'is_verified',
        'profile_completion_pct', 'last_active_at',
    ];

    public function findByUserId(int $userId): ?CandidateProfile
    {
        return $this->where('user_id', $userId)->first();
    }
}
