5.1 - Persisting the Order Amount

This commit is contained in:
Adam Wathan
2016-11-17 10:26:08 -05:00
parent 21e61426ef
commit bb6944e63b
3 changed files with 6 additions and 2 deletions

View File

@@ -58,7 +58,10 @@ class Concert extends Model
throw new NotEnoughTicketsException;
}
$order = $this->orders()->create(['email' => $email]);
$order = $this->orders()->create([
'email' => $email,
'amount' => $ticketQuantity * $this->ticket_price,
]);
foreach ($tickets as $ticket) {
$order->tickets()->save($ticket);