<?php

namespace App\Helpers;

use Illuminate\Support\Facades\Auth;

class RoleHelper
{
    /**
     * Check if user can create purchase requests
     */
    public static function canCreatePR(): bool
    {
        // For now, all authenticated users can create PRs
        // You can modify this based on your role system
        return Auth::check();
    }

    /**
     * Check if user can approve/reject purchase requests
     */
    public static function canApprovePR(): bool
    {
        // For now, all authenticated users can approve PRs
        // You can modify this based on your role system (e.g., check for 'approver' role)
        return Auth::check();
    }

    /**
     * Check if user can view all purchase requests or only their own
     */
    public static function canViewAllPRs(): bool
    {
        // For now, all authenticated users can view all PRs
        // You can modify this based on your role system
        return Auth::check();
    }

    /**
     * Check if user can change status of a specific PR
     */
    public static function canChangeStatus($purchaseRequest): bool
    {
        // User can change status if they are the creator (for draft/submitted) or if they have approval rights
        return Auth::id() === $purchaseRequest->user_id || self::canApprovePR();
    }
}
