本文整理匯總了PHP中Model_Order::forge方法的典型用法代碼示例。如果您正苦於以下問題:PHP Model_Order::forge方法的具體用法?PHP Model_Order::forge怎麽用?PHP Model_Order::forge使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Model_Order
的用法示例。
在下文中一共展示了Model_Order::forge方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: action_order
public function action_order()
{
define("SECONDS_PER_DAY", 3600 * 24);
$now = time();
$cart = Session::get('cart');
$user = Model_User::find($this->sessUser->id);
$cart_info = [];
$order = Model_Order::forge();
$order->user_id = $user->id;
$order->created_at = $now;
$order->save();
if (!is_null($cart)) {
foreach ($cart as $product_id => $quantity) {
$product = Model_Product::find($product_id);
$order_product = Model_OrderProduct::forge();
$order_product->order_id = $order->id;
$order_product->product_id = $product->id;
$order_product->quantity = $quantity;
$order_product->price = $product->price;
$order_product->save();
}
}
Session::delete('cart');
return Response::redirect('/cart');
}
示例2: get_order
/**
* 創建訂單對象
* @return static
*/
public static function get_order()
{
$data = \Input::post();
if (!static::valid_data()) {
return false;
}
$order = \Model_Order::forge($data);
$order->order_no = static::get_order_on();
return $order;
}
示例3: action_bid
/**
* 出價
* @param int $id 拍品ID
*/
public function action_bid($id = 0)
{
if (\Input::method() == 'POST') {
$msg = ['status' => 'err', 'msg' => '', 'errcode' => 10];
$order_no = \Model_Order::get_order_on();
$data = ['order_no' => $order_no, 'order_type' => 'AUCTION', 'buyer_id' => \Auth::get_user()->id, 'from_id' => \Session::get('seller')->id, 'total_fee' => \Input::post('bid'), 'original_fee' => \Input::post('bid')];
$order = \Model_Order::forge($data);
$order->details = [\Model_OrderDetail::forge(['goods_id' => $id, 'num' => 1, 'price' => \Input::post('bid')])];
if ($order->save()) {
$msg = ['status' => 'succ', 'msg' => '', 'errcode' => 0];
}
if (\Input::is_ajax()) {
die(json_encode($msg));
}
\Session::set_flash('msg', $msg);
}
}
示例4: load_preferential
/**
* 添加優惠信息
*/
protected function load_preferential($data)
{
if (!$this->order) {
$this->order = \Model_Order::forge();
}
$this->order->preferentials = [];
$fee = 0;
foreach ($data as $item) {
array_push($this->order->preferentials, \Model_OrderPreferential::forge($item));
$fee += $item->fee;
}
$this->order->preferential_fee = $fee;
}