<?php

namespace App\Modules\HR\Recruitment\Policies;

use App\Models\User;
use App\Modules\HR\Recruitment\Models\RecruitmentCandidate;

class RecruitmentCandidatePolicy
{
    public function viewAny(User $user): bool
    {
        return $user->can('recruitment.view');
    }

    public function view(User $user, RecruitmentCandidate $candidate): bool
    {
        return (int) $user->tenant_id === (int) $candidate->tenant_id
            && $user->can('recruitment.view');
    }

    public function create(User $user): bool
    {
        return $user->can('recruitment.create');
    }

    public function update(User $user, RecruitmentCandidate $candidate): bool
    {
        return (int) $user->tenant_id === (int) $candidate->tenant_id
            && $user->can('recruitment.manage');
    }

    public function delete(User $user, RecruitmentCandidate $candidate): bool
    {
        return (int) $user->tenant_id === (int) $candidate->tenant_id
            && $user->can('recruitment.manage');
    }
}
