Add Leave Balances and Biometric Attendance menu items for employees and handle view-only permissions
This commit is contained in:
@@ -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());
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user