<?php

namespace App\Modules\HR\Overtime\Policies;

use App\Models\User;
use App\Modules\HR\Overtime\Models\OvertimeRequest;
use App\Modules\HR\Overtime\Support\OvertimeRequestStatus;

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

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

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

    public function review(User $user, OvertimeRequest $request): bool
    {
        return $request->status === OvertimeRequestStatus::PENDING
            && $user->can('overtime.review');
    }
}
