mirror of
https://github.com/nothingworksinc/ticketbeast.git
synced 2026-02-05 00:48:41 +00:00
5.4 - Extracting a Named Constructor
This commit is contained in:
@@ -69,16 +69,7 @@ class Concert extends Model
|
||||
|
||||
public function createOrder($email, $tickets)
|
||||
{
|
||||
$order = Order::create([
|
||||
'email' => $email,
|
||||
'amount' => $tickets->sum('price'),
|
||||
]);
|
||||
|
||||
foreach ($tickets as $ticket) {
|
||||
$order->tickets()->save($ticket);
|
||||
}
|
||||
|
||||
return $order;
|
||||
return Order::forTickets($tickets, $email);
|
||||
}
|
||||
|
||||
public function addTickets($quantity)
|
||||
|
||||
Reference in New Issue
Block a user