5.5 - Precomputing the Order Amount

This commit is contained in:
Adam Wathan
2016-11-18 18:26:56 -05:00
parent 45104cd59b
commit 510a60fcd3
4 changed files with 8 additions and 9 deletions

View File

@@ -8,11 +8,11 @@ class Order extends Model
{
protected $guarded = [];
public static function forTickets($tickets, $email)
public static function forTickets($tickets, $email, $amount)
{
$order = self::create([
'email' => $email,
'amount' => $tickets->sum('price'),
'amount' => $amount,
]);
foreach ($tickets as $ticket) {