<?php
namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;

class InvoiceController extends Controller
{
    public function index(Request $request)
    {
        $billings = DB::table('billings')
            ->leftJoin('customers','customers.id','=','billings.customer_id')
            ->select('billings.*','customers.name','customers.phone','customers.email','customers.address')
            ->where('billings.id',$request->billing_id)
            ->get();
            
        $billingItems = DB::table('billing_items')
            ->where('billing_id',$request->billing_id)
            ->get();

        return view('admin/invoice',['billing'=>$billings[0],'billingItems'=>$billingItems,'title'=>'AR Clean Invoice']);
    }
    
}
?>