<?php

namespace App\Models;

use CodeIgniter\Model;

class CandidateUnlockModel extends Model
{
    protected $table         = 'candidate_unlocks';
    protected $useTimestamps = false;
    protected $allowedFields = ['agency_id', 'recruiter_id', 'candidate_profile_id', 'unlock_type', 'credits_spent', 'unlocked_at'];

    public function hasUnlocked(int $agencyId, int $candidateProfileId, string $unlockType): bool
    {
        return $this->where('agency_id', $agencyId)
            ->where('candidate_profile_id', $candidateProfileId)
            ->where('unlock_type', $unlockType)
            ->first() !== null;
    }

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