public function getAllPackagesByID($id) { $allPackages = Packages::where('pc_id', $id)->get(); return $allPackages; }
public function MenuTable($header, $data, $reservation, $fpdf) { // Colors, line width and bold font $fpdf->Ln(); $fpdf->SetFillColor(79, 74, 72); $fpdf->SetTextColor(255); $fpdf->SetDrawColor(128, 0, 0); $fpdf->SetLineWidth(0.3); $fpdf->SetFont('', 'B'); // Header $w = array(18, 85, 60, 18); for ($i = 0; $i < count($header); $i++) { $fpdf->Cell($w[$i], 7, $header[$i], 1, 0, 'C', true); } $fpdf->Ln(); // Color and font restoration $fpdf->SetFillColor(224, 235, 255); $fpdf->SetTextColor(0); $fpdf->SetFont(''); // Data $fill = false; foreach ($reservation->items as $items) { $fpdf->Cell($w[0], 6, "Equip", 'LR', 0, 'L', $fill); $fpdf->Cell($w[1], 6, $items->model_number, 'LR', 0, 'L', $fill); $fpdf->Cell($w[2], 6, $items->average_price . " x " . $items->pivot->qty, 'LR', 0, 'C', $fill); $fpdf->Cell($w[3], 6, $items->average_price * $items->pivot->qty, 'LR', 0, 'R', $fill); $fpdf->Ln(); $fill = !$fill; } $i = 0; $day = 0; foreach ($data as $row) { if ($row->pivot->package) { if ($day == 0) { $fpdf->Cell($w[0], 6, "Day " . $row->pivot->day, 'LR', 0, 'L', $fill); $fpdf->Cell($w[1], 6, Packages::where('id', '=', $row->pivot->package)->pluck('name'), 'LR', 0, 'L', $fill); $fpdf->Cell($w[2], 6, '', 'LR', 0, 'C', $fill); $fpdf->Cell($w[3], 6, Packages::where('id', '=', $row->pivot->package)->pluck('price'), 'LR', 0, 'R', $fill); $fpdf->Ln(); $fpdf->Cell($w[0], 6, "", 'LR', 0, 'L', $fill); $fpdf->Cell($w[1], 6, '- ' . $row->name, 'LR', 0, 'L', $fill); $fpdf->Cell($w[2], 6, 'Included in Package', 'LR', 0, 'C', $fill); $fpdf->Cell($w[3], 6, '', 'LR', 0, 'R', $fill); } else { $fpdf->Cell($w[0], 6, "", 'LR', 0, 'L', $fill); $fpdf->Cell($w[1], 6, '- ' . $row->name, 'LR', 0, 'L', $fill); $fpdf->Cell($w[2], 6, 'Included in Package', 'LR', 0, 'C', $fill); $fpdf->Cell($w[3], 6, '', 'LR', 0, 'R', $fill); } $day++; } else { $fpdf->Cell($w[0], 6, "Day " . $row->pivot->day, 'LR', 0, 'L', $fill); $fpdf->Cell($w[1], 6, $row->name, 'LR', 0, 'L', $fill); $fpdf->Cell($w[2], 6, $row->price . " x " . $reservation->pax, 'LR', 0, 'C', $fill); $fpdf->Cell($w[3], 6, $row->price * $reservation->pax, 'LR', 0, 'R', $fill); } $fpdf->Ln(); $fill = !$fill; } // Closing line $fpdf->Cell(array_sum($w), 0, '', 'T'); }