Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 18
0.00% covered (danger)
0.00%
0 / 4
CRAP
0.00% covered (danger)
0.00%
0 / 1
PdfController
0.00% covered (danger)
0.00%
0 / 18
0.00% covered (danger)
0.00%
0 / 4
20
0.00% covered (danger)
0.00%
0 / 1
 purchase_invoice
0.00% covered (danger)
0.00%
0 / 5
0.00% covered (danger)
0.00%
0 / 1
2
 sale_invoice
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
 total_customer_sale
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 1
2
 single_customer_order_list
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace App\Http\Controllers\admin;
4
5use App\Http\Controllers\Controller;
6use App\Models\admin\Purchase;
7use App\Models\admin\PurchaseDetails;
8use App\Models\admin\Sale;
9use App\Models\admin\SalePayment;
10use Barryvdh\DomPDF\Facade\Pdf;
11
12class PdfController extends Controller
13{
14    public function purchase_invoice($id)
15    {
16        $purchase = Purchase::query()
17            ->with(['supplier', 'purchase_details', 'purchase_payment'])
18            ->findOrFail($id);
19
20        return Pdf::loadView('admin.purchase.invoice', compact('purchase'))
21            ->download('purchase-invoice-' . $purchase->ref . '.pdf');
22    }
23
24    public function sale_invoice($id)
25    {
26        $sale_invoice = Sale::query()->where('id', $id)->with(['customer', 'sale_details', 'sale_payment'])->first();
27        $pdf = Pdf::loadView('admin.sales.invoice', compact('sale_invoice'));
28
29        return $pdf->download('invoice.pdf');
30        //       return view('admin.sales.details')->with($data);
31    }
32
33    public function total_customer_sale()
34    {
35        //       $sale_invoice= Sale::query()->where('id', $id)->with(['customer', 'sale_details', 'sale_payment'])->first();
36        $customer_reports = Sale::orderBy('customer_id', 'desc')
37            ->with('customer', 'sale_details', 'sale_payment')
38            ->get()
39            ->groupBy('customer_id');
40        $total_sale_amount = SalePayment::query()->sum('total');
41        $total_paid_amount = SalePayment::query()->sum('paid');
42        //       return view('admin.report.pdf.customer.all_customer_sale',compact('customer_reports','total_sale_amount','total_paid_amount'));
43        $pdf = Pdf::loadView('admin.report.pdf.customer.all_customer_sale', compact('customer_reports', 'total_sale_amount', 'total_paid_amount'));
44
45        return $pdf->download('Customer all time Sale.pdf');
46    }
47
48    public function single_customer_order_list($customer_id)
49    {
50        $sale_list = Sale::query()->where('customer_id', $customer_id)->with('customer', 'sale_details', 'sale_payment')->first();
51
52        return view('admin.report.pdf.customer.all_customer_sale', compact('sale_list'));
53    }
54}