<?php

use App\Models\ModulePermission;
use Illuminate\Support\Facades\Auth;

if (!function_exists('hasModulePermission')) {
    function hasModulePermission($module, $permission)
    {
        $user = Auth::user();

        if (!$user) return false;

        $modulePermission = ModulePermission::where('employee_id', $user->user_id)
            ->where('module_permission', $module)
            ->first();
            // dd ($modulePermission);

        return $modulePermission && $modulePermission->$permission === 'Y';
    }
}
