<?php

namespace App\Models;

use CodeIgniter\Model;

class CandidateExperienceModel extends Model
{
    protected $table         = 'candidate_experiences';
    protected $allowedFields = ['candidate_profile_id', 'job_title', 'company_name', 'location', 'start_date', 'end_date', 'is_current', 'description'];
    protected $validationRules = [
        'job_title'    => 'required|max_length[150]',
        'company_name' => 'required|max_length[150]',
        'start_date'   => 'required|valid_date',
    ];

    public function forProfile(int $candidateProfileId): array
    {
        return $this->where('candidate_profile_id', $candidateProfileId)->orderBy('start_date', 'DESC')->findAll();
    }
}
