public function getLeavesListPdf($id) { $audit = AuditTrail::create(['user_id' => Auth::id(), 'role' => 'Employee Management Admin', 'action' => 'printed Leave balances of All employees.']); if ($id == "*") { $users = User::all(); } else { $users = User::where('department_id', $id)->get(); } Fpdf::AddPage(); Fpdf::Image('img/dap.jpg', 40, 0, 150); Fpdf::Ln(35); Fpdf::SetFont('Arial', 'B', 11); Fpdf::SetTextColor(0, 0, 0); Fpdf::Cell(300, 20, 'Date Generated: ' . date("F j, Y"), 0, 2, 'C', 0); Fpdf::Cell(18, 7, 'Leave List', 0, 2, 'C', 0); Fpdf::SetFont('Arial', 'B', 7); Fpdf::SetTextColor(0, 0, 0); Fpdf::Cell(18, 7, 'ID', 1); Fpdf::Cell(24, 7, 'Name', 1); Fpdf::Cell(30, 7, 'Department', 1); Fpdf::Cell(9, 7, 'VL', 1); Fpdf::Cell(9, 7, 'SL', 1); Fpdf::Cell(9, 7, 'PL', 1); Fpdf::Cell(9, 7, 'ML', 1); Fpdf::Cell(9, 7, 'BL', 1); Fpdf::Ln(); Fpdf::SetFont('Arial', '', 7); foreach ($users as $user) { Fpdf::Cell(18, 7, $user->id, 1); Fpdf::Cell(24, 7, $user->firstname, 1); Fpdf::Cell(30, 7, $user->department->name, 1); $leaves = LeaveBalance::where('user_id', $user->id)->get(); foreach ($leaves as $leave) { Fpdf::Cell(9, 7, $leave->balance, 1); } Fpdf::Ln(); } Fpdf::SetY(-35); Fpdf::AliasNbPages('{nb}'); Fpdf::SetFont('Arial', 'I', 10); Fpdf::SetTextColor(0, 0, 0); Fpdf::Cell(0, 10, 'Page ' . Fpdf::PageNo() . '/{nb}', 0, 0, 'C'); Fpdf::Output(); exit; }