Last active
March 9, 2016 17:19
-
-
Save FWSimon/6c13e036f3e4152ed64e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function Preview(Request $request) | |
{ | |
$inputs = $request->all(); | |
$invoiceItems = array_map(function ($quantity, $description, $price) { | |
return [ | |
'quantity' => $quantity, | |
'description' => $description, | |
'price' => $price | |
]; | |
}, $inputs['quantity'], $inputs['description'], $inputs['price']); | |
$client = Client::find($inputs['client']); | |
//combine dates | |
$due_date = $request->year .'-'.$request->month .'-'.$request->day; | |
//Save invoice | |
$invoice = new Invoice; | |
$invoice->client_id = $request->client; | |
$invoice->user_id = Auth::user()->id; | |
$invoice->due_date = $due_date; | |
$invoice->status = 'created'; | |
$invoice->amount = $request->amount; | |
$invoice->save(); | |
DB::table('invoiceItems')->insert([$invoiceItems]); | |
dd($invoiceItems); | |
dd('insert'); | |
return view('invoices.preview', compact('inputs', 'client', 'invoiceItems')); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment