<?php

namespace App\Models;

use CodeIgniter\Model;

class SavedCandidateModel extends Model
{
    protected $table         = 'saved_candidates';
    protected $useTimestamps = false;
    protected $allowedFields = ['agency_id', 'recruiter_id', 'candidate_profile_id', 'created_at'];

    public function forRecruiter(int $recruiterId): array
    {
        return $this->where('recruiter_id', $recruiterId)->orderBy('created_at', 'DESC')->findAll();
    }

    public function isSaved(int $recruiterId, int $candidateProfileId): bool
    {
        return $this->where('recruiter_id', $recruiterId)->where('candidate_profile_id', $candidateProfileId)->first() !== null;
    }
}
