public function checkout(Request $request) { // 建立訂單 $order = new Order(); $order->setProducts($request->get('product_ids')); $order->setAccount($request->get('account_id')); // 處理訂單 $orderProcessor = new OrderProcessor(new CreditCardBiller(), new OrderRepository()); echo "<h4>訂單處理中...</h4>"; $orderId = $orderProcessor->process($order); return "<h2>Done, 訂單 ID: " . $orderId . "</h2>" . "<h2>{$order->getAccount()->name}</h2>" . "<h2>{$order->getAmount()}</h2>"; }
public function logOrder(Order $order) { $id = DB::table('orders')->insertGetId(array('account' => $order->getAccount()->id, 'amount' => $order->getAmount(), 'created_at' => Carbon::now())); return $id; }