当前位置: 首页>>代码示例>>PHP>>正文


PHP Order::create方法代码示例

本文整理汇总了PHP中Order::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Order::create方法的具体用法?PHP Order::create怎么用?PHP Order::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Order的用法示例。


在下文中一共展示了Order::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addAction

 public function addAction()
 {
     $validator = Validator::make(Input::all(), ["account" => "required|exists:account,id", "items" => "required"]);
     if ($validator->passes()) {
         $order = Order::create(["account_id" => Input::get("account")]);
         try {
             $items = json_decode(Input::get("items"));
         } catch (Exception $e) {
             return Response::json(["status" => "error", "errors" => ["items" => ["Invalid items format."]]]);
         }
         $total = 0;
         foreach ($items as $item) {
             $orderItem = OrderItem::create(["order_id" => $order->id, "product_id" => $item->product_id, "quantity" => $item->quantity]);
             $product = $orderItem->product;
             $orderItem->price = $product->price;
             $orderItem->save();
             $product->stock -= $item->quantity;
             $product->save();
             $total += $orderItem->quantity * $orderItem->price;
         }
         $result = $this->gateway->pay(Input::get("number"), Input::get("expiry"), $total, "usd");
         if (!$result) {
             return Response::json(["status" => "error", "errors" => ["gateway" => ["Payment error"]]]);
         }
         $account = $order->account;
         $document = $this->document->create($order);
         $this->messenger->send($order, $document);
         return Response::json(["status" => "ok", "order" => $order->toArray()]);
     }
     return Response::json(["status" => "error", "errors" => $validator->errors()->toArray()]);
 }
开发者ID:gitter-badger,项目名称:tutorial-laravel-4-e-commerce,代码行数:31,代码来源:OrderController.php

示例2: run

 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Order::create([]);
     }
 }
开发者ID:yanguanglan,项目名称:sz,代码行数:7,代码来源:OrdersTableSeeder.php

示例3: create

 public function create()
 {
     if (!isset($_POST['quantity']) || !isset($_POST['product_id']) || !isset($_POST['product_price'])) {
         return call('pages', 'error');
     }
     if (isAdmin()) {
         $_SESSION['alert'] = "Admin is not able to buy products";
         return header("Location: index.php?controller=products&action=index");
     }
     if (!isset($_SESSION['id'])) {
         $_SESSION['alert'] = "Please log in before shopping";
         return header("Location: index.php?controller=products&action=index");
     }
     if (!Order::isValid($_SESSION['id'])) {
         $_SESSION['alert'] = "Before you can buy products, you must provide necessary perfonal information";
         return header("Location: index.php?controller=products&action=index");
     }
     if (!isset($_SESSION['orderID'])) {
         $_SESSION['orderID'] = Order::create($_SESSION['id']);
     }
     require_once 'models/order_detail.php';
     if (OrderDetail::check($_SESSION['orderID'], $_POST['product_id'])) {
         OrderDetail::addQuantity($_SESSION['orderID'], $_POST['product_id'], $_POST['quantity']);
     } else {
         OrderDetail::create($_SESSION['orderID'], $_POST['product_id'], $_POST['product_price'], $_POST['quantity']);
     }
     $_SESSION['notice'] = "Added product to basket";
     header("Location: index.php?controller=products&action=index");
 }
开发者ID:Hield,项目名称:e-commerce,代码行数:29,代码来源:orders_controller.php

示例4: addProductToCart

 public function addProductToCart(Product $prd, $opts)
 {
     SesState::addProduct($prd);
     // make an new order
     $order = Order::create($this, $prd, $opts);
     Pdb::insert(array('customer' => $this->id, 'small_order' => $order->id), Cart::$table);
     return $order;
 }
开发者ID:name3,项目名称:cheng,代码行数:8,代码来源:Customer.php

示例5: run

 /**
  * Auto generated seed file
  *
  * @return void
  */
 public function run()
 {
     \DB::table('orders')->delete();
     $faker = Faker\Factory::create();
     foreach (range(1, 10) as $id) {
         Order::create(['status' => $faker->randomElement(array('0', '1'))]);
     }
 }
开发者ID:p-tricky,项目名称:CAEWeb,代码行数:13,代码来源:OrdersTableSeeder.php

示例6: order

function order($data)
{
    global $user;
    $data['userid'] = $user->id;
    $data['status'] = "Processing";
    $order = Order::create($data);
    return $order;
}
开发者ID:helloworldprojects,项目名称:FoodWeb,代码行数:8,代码来源:api.php

示例7: run

 public function run()
 {
     $tables = Table::lists('id');
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Order::create(['table_id' => $faker->randomElement($tables)]);
     }
 }
开发者ID:udayrockstar,项目名称:RestaurantManager,代码行数:8,代码来源:OrdersTableSeeder.php

示例8: store

 /**
  * Store a newly created order in storage.
  *
  * @return Response
  */
 public function store()
 {
     $validator = Validator::make($data = Input::all(), Order::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     Order::create($data);
     return Redirect::route('orders.index');
 }
开发者ID:vnzacky,项目名称:exp_services,代码行数:14,代码来源:OrdersController.php

示例9: run

 public function run()
 {
     Order::create(["company_id" => 1, "product_id" => 1, "start_date" => "2014-06-02", "end_date" => "2014-06-02", "amount" => "10", "week_number" => "39", "max_amount" => "1000", "max_amount_daily" => "100", "min_amount" => "900", "price" => "30000", "period" => 2, "confirmed" => false]);
     Order::create(["company_id" => 1, "product_id" => 1, "start_date" => "2014-07-04", "end_date" => "2014-07-04", "amount" => "20", "week_number" => "39", "max_amount" => "1000", "max_amount_daily" => "100", "min_amount" => "900", "price" => "30000", "period" => 2, "confirmed" => false]);
     Order::create(["company_id" => 1, "product_id" => 2, "start_date" => "2014-09-04", "end_date" => "2014-09-04", "amount" => "70", "week_number" => "42", "max_amount" => "1000", "max_amount_daily" => "100", "min_amount" => "900", "price" => "30000", "period" => 2, "confirmed" => false]);
     Order::create(["company_id" => 1, "product_id" => 2, "start_date" => "2014-09-04", "end_date" => "2014-09-04", "amount" => "30", "week_number" => "44", "max_amount" => "1000", "max_amount_daily" => "100", "min_amount" => "900", "price" => "30000", "period" => 2, "confirmed" => false]);
     Order::create(["company_id" => 1, "product_id" => 2, "start_date" => "2014-09-04", "end_date" => "2014-09-04", "amount" => "9", "week_number" => "43", "max_amount" => "1000", "max_amount_daily" => "100", "min_amount" => "900", "price" => "30000", "period" => 2, "confirmed" => false]);
     Order::create(["company_id" => 1, "product_id" => 1, "start_date" => "2014-09-04", "end_date" => "2014-09-04", "amount" => "9", "week_number" => "43", "max_amount" => "1000", "max_amount_daily" => "100", "min_amount" => "900", "price" => "30000", "period" => 2, "confirmed" => false]);
 }
开发者ID:hilmysyarif,项目名称:erp,代码行数:9,代码来源:OrdersTableSeeder.php

示例10: run

 public function run()
 {
     $faker = $this->getFaker();
     $accounts = Account::all();
     foreach ($accounts as $account) {
         for ($i = 0; $i < rand(-1, 5); $i++) {
             Order::create(["account_id" => $account->id]);
         }
     }
 }
开发者ID:Basvkempen1,项目名称:simpleShop,代码行数:10,代码来源:OrderTableSeeder.php

示例11: store

 /**
  * Store a newly created resource in storage.
  * POST /orders
  *
  * @return Response
  */
 public function store()
 {
     $input = Input::only('product_id', 'start_date', 'end_date', 'amount', 'max_amount', 'max_amount_daily', 'min_amount', 'price', 'period');
     $this->orderCreation->validate($input);
     $order = Order::create($input);
     $order->company_id = Auth::user()->company_id;
     $start_date = Input::only('start_date')['start_date'];
     $order->week_number = get_week_from_date($start_date);
     $order->save();
     return Redirect::action('UsersController@index');
 }
开发者ID:hilmysyarif,项目名称:erp,代码行数:17,代码来源:OrdersController.php

示例12: store

 /**
  * Store a newly created order in storage.
  *
  * @return Response
  */
 public function store()
 {
     $data = Input::all();
     // $validator = Validator::make($data, Order::$rules);
     // if ($validator->fails())
     // {
     // 	return Redirect::back()->withErrors($validator)->withInput();
     // }
     Order::create($data);
     return Response::json(['status' => 'OK']);
 }
开发者ID:Park-It,项目名称:parkit.dev,代码行数:16,代码来源:OrdersController.php

示例13: registerconfig

 public function registerconfig()
 {
     $order = ShoppingCart::curr();
     //hack to make components work when there is no order
     if (!$order) {
         $order = Order::create();
     }
     $config = new CheckoutComponentConfig($order, false);
     $config->addComponent(new CustomerDetailsCheckoutComponent());
     $config->addComponent(new MembershipCheckoutComponent());
     return $config;
 }
开发者ID:helpfulrobot,项目名称:silvershop-core,代码行数:12,代码来源:CheckoutStep_Membership.php

示例14: postCreate

 /**
  * This function create order
  * when data is posted from 
  * /admin/order/create
  */
 public function postCreate()
 {
     // Check validation
     $validator = Validator::make(Input::all(), Order::$rulesForCreate);
     // If failed the redirect to order-create-get route with
     // validation error and input old
     if ($validator->fails()) {
         return Redirect::route('order-create-get')->withErrors($validator)->withInput();
     }
     Order::create(array('member_id' => Input::get('member_id'), 'movie_id' => Input::get('movie_id'), 'employee_id' => Session::get('employee_id'), 'from' => DateFormat::store(Input::get('from')), 'to' => DateFormat::store(Input::get('to')), 'status' => '1'));
     return View::make('adminArea.order.create')->with('success', 'Order has been created successfully');
 }
开发者ID:madiarsa,项目名称:DVD-Rental,代码行数:17,代码来源:OrderController.php

示例15: postEventBuy

 public function postEventBuy($event_id)
 {
     $validator = Validator::make(Input::all(), array('email' => 'required|email', 'first_name' => 'required', 'last_name' => 'required', 'address' => 'required', 'city' => 'required', 'zip_code' => 'required', 'phone' => 'required'));
     if ($validator->fails()) {
         return Redirect::route('events.event-buy')->withErrors($validator)->withInput();
     } else {
         $price = Order::find($event_id)->price;
         $user_id = Auth::user()->id;
         $order = Order::create(array('customer_id' => $user_id, 'event_id' => $event_id, 'price' => $price));
         if ($order) {
             return Redirect::route('events')->with('global', 'Thank you for your order.');
         }
     }
 }
开发者ID:tallcoder,项目名称:ticketify,代码行数:14,代码来源:EventController.php


注:本文中的Order::create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。