<?php

namespace App\Modules\HR\Recruitment\Policies;

use App\Models\User;
use App\Modules\HR\Recruitment\Models\RecruitmentHiring;
use App\Modules\HR\Recruitment\Models\RecruitmentOfferLetter;

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

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

    public function hire(User $user, RecruitmentOfferLetter $offerLetter): bool
    {
        return (int) $user->tenant_id === (int) $offerLetter->tenant_id
            && $user->can('recruitment.manage')
            && $user->can('employees.create');
    }
}
