mirror of
https://github.com/nothingworksinc/ticketbeast.git
synced 2026-02-04 06:48:32 +00:00
51 - Green with Feature Envy
This commit is contained in:
@@ -37,7 +37,7 @@ class ConcertOrdersController extends Controller
|
||||
$this->paymentGateway->charge($reservation->totalCost(), request('payment_token'));
|
||||
|
||||
// Create an order for those tickets
|
||||
$order = Order::forTickets($reservation->tickets(), $reservation->email(), $reservation->totalCost());
|
||||
$order = $reservation->complete();
|
||||
|
||||
return response()->json($order, 201);
|
||||
|
||||
|
||||
@@ -22,18 +22,6 @@ class Order extends Model
|
||||
return $order;
|
||||
}
|
||||
|
||||
public static function fromReservation($reservation)
|
||||
{
|
||||
$order = self::create([
|
||||
'email' => $reservation->email(),
|
||||
'amount' => $reservation->totalCost(),
|
||||
]);
|
||||
|
||||
$order->tickets()->saveMany($reservation->tickets());
|
||||
|
||||
return $order;
|
||||
}
|
||||
|
||||
public function concert()
|
||||
{
|
||||
return $this->belongsTo(Concert::class);
|
||||
|
||||
@@ -28,6 +28,11 @@ class Reservation
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
public function complete()
|
||||
{
|
||||
return Order::forTickets($this->tickets(), $this->email(), $this->totalCost());
|
||||
}
|
||||
|
||||
public function cancel()
|
||||
{
|
||||
foreach ($this->tickets as $ticket) {
|
||||
|
||||
Reference in New Issue
Block a user