本文整理汇总了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()]);
}
示例2: run
public function run()
{
$faker = Faker::create();
foreach (range(1, 10) as $index) {
Order::create([]);
}
}
示例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");
}
示例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;
}
示例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'))]);
}
}
示例6: order
function order($data)
{
global $user;
$data['userid'] = $user->id;
$data['status'] = "Processing";
$order = Order::create($data);
return $order;
}
示例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)]);
}
}
示例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');
}
示例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]);
}
示例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]);
}
}
}
示例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');
}
示例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']);
}
示例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;
}
示例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');
}
示例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.');
}
}
}