<?php

namespace App\Modules\HR\Contracts\Policies;

use App\Models\User;
use App\Modules\HR\Contracts\Models\EmploymentContract;

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

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

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

    public function update(User $user, EmploymentContract $contract): bool
    {
        return (int) $user->tenant_id === (int) $contract->tenant_id
            && $user->can('contracts.update');
    }

    public function deactivate(User $user, EmploymentContract $contract): bool
    {
        return (int) $user->tenant_id === (int) $contract->tenant_id
            && $user->can('contracts.deactivate');
    }
}
