Add Leave Balances and Biometric Attendance menu items for employees and handle view-only permissions

This commit is contained in:
2026-07-01 10:02:32 +08:00
parent a5074282aa
commit 5b7a41927b
3 changed files with 43 additions and 4 deletions

View File

@@ -16,12 +16,12 @@ class LeaveBalanceController extends Controller
{
public function index(Request $request)
{
if (Auth::user()->can('manage-leave-balances')) {
if (Auth::user()->can('manage-leave-balances') || Auth::user()->can('view-leave-balances')) {
$query = LeaveBalance::with(['employee', 'leaveType', 'leavePolicy', 'creator'])
->where(function ($q) {
if (Auth::user()->can('manage-any-leave-balances')) {
$q->whereIn('created_by', getCompanyAndUsersId());
} elseif (Auth::user()->can('manage-own-leave-balances')) {
} elseif (Auth::user()->can('manage-own-leave-balances') || Auth::user()->can('view-leave-balances') || Auth::user()->type === 'employee') {
$q->where('created_by', Auth::id())->orWhere('employee_id', Auth::id());
} else {
$q->whereRaw('1 = 0');
@@ -115,7 +115,7 @@ class LeaveBalanceController extends Controller
// Get employees for filter dropdown (compatible with getFilteredEmployees logic)
$employeeQuery = Employee::whereIn('created_by', getCompanyAndUsersId());
if (Auth::user()->can('manage-own-leave-balances') && !Auth::user()->can('manage-any-leave-balances')) {
if ((Auth::user()->can('manage-own-leave-balances') || Auth::user()->can('view-leave-balances') || Auth::user()->type === 'employee') && !Auth::user()->can('manage-any-leave-balances')) {
$employeeQuery->where(function ($q) {
$q->where('created_by', Auth::id())->orWhere('user_id', Auth::id());
});