本文整理汇总了PHP中app\Order::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Order::save方法的具体用法?PHP Order::save怎么用?PHP Order::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Order
的用法示例。
在下文中一共展示了Order::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkOut
public function checkOut(Request $request)
{
$address = \StringHelper::filterString($request->input('address'));
$name = \StringHelper::filterString($request->input('name'));
$content = \StringHelper::filterString($request->input('comments'));
$phone = \StringHelper::filterString($request->input('phone'));
$count = Cart::count();
if ($phone != "" && $name != "" && $content != "" && $count > 0) {
$order = new Order();
$order->order_name = $name;
$order->status = 1;
$order->active = 1;
$order->order_comment = $content;
$order->order_address = $address;
$order->order_phone = $phone;
$order->save();
$cart = Cart::content();
foreach ($cart as $item) {
$order_detail = new OrderDetail();
$order_detail->dish_id = $item->id;
$order_detail->dish_number = $item->qty;
$order_detail->order_id = $order->id;
$order_detail->save();
}
Cart::destroy();
return Redirect::to(url('menu'))->with('message', 'Order Success !. You can continue buy now !');
} else {
return Redirect::to(url('checkout'))->with('message', 'Order Fail !. Something Wrong !');
}
}
示例2: store
/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return Response
*/
public function store(Request $request)
{
$order = new Order();
$order->setTotal($request->input('total'));
$order->save();
foreach ($request->input('sweeties') as $sweetyId) {
$order->sweeties()->attach(Sweety::findOrFail($sweetyId));
}
$order->save();
return JsonResponse::create($order->load('sweeties'));
}
示例3: store
public function store()
{
$input = Input::all();
$salesman = isset($input['salesman']) ? $input['salesman'] : null;
$customer = Customer::firstOrNew(['name' => $input['name'], 'address' => $input['address']]);
$customer->save();
$order = new Order();
$order->customer_id = $customer->id;
$order->salesman_id = $salesman;
$order->date = $input['date'];
$order->type = $input['type'];
$order->save();
foreach ($input['box_id'] as $i => $box_id) {
$orderItem = new OrderItem();
$orderItem->order_id = $order->id;
$orderItem->product_id = Box::find($box_id)->product->id;
$orderItem->box_id = $box_id;
$orderItem->no_of_box = $input['no_of_box'][$i];
$orderItem->no_of_packs = $input['no_of_packs'][$i];
$orderItem->amount = $input['amount'][$i];
$orderItem->selling_price = $input['selling_price'][$i];
$orderItem->save();
}
return view('order.addmore');
}
示例4: postCheckout
public function postCheckout()
{
$order_count = count(Order::all()) + 2;
$order_number = "MEI-" . date('mdY') . "-" . $order_count;
$product_ids = Session::get("pro_ids");
$price = Session::get("price");
$duration = Session::get("duration");
$quantity = Input::get("quantity");
$total_price_sum = Input::get("total-price-sum");
$subtotal_price_sum = Input::get("subtotal-price-sum");
foreach ($product_ids as $product_id) {
$pro = Product::find($product_id);
$order = new Order(array('product_id' => $product_id, 'order_number' => $order_number, 'quantity' => $quantity[$product_id], 'subtotal' => $subtotal_price_sum[$product_id], 'duration' => $duration[$product_id], 'price' => $price[$product_id]));
$order->save();
}
$order_confirmed = new ConfirmOrders(array('order_number' => $order_number, 'total' => $total_price_sum, 'user_id' => Auth::user()->id));
$order_confirmed->save();
$order_confirmed = ConfirmOrders::find($order_confirmed->id);
$user_order = $order_confirmed->user;
$order_details = Order::where('order_number', $order_confirmed->order_number)->get();
Mail::send(['html' => 'order-received'], ['order_details' => $order_details, 'order_confirmed' => $order_confirmed, 'user_order' => $user_order], function ($message) use($user_order) {
$message->from('info@nmkelectronics.com', 'MEI - Student Rental');
$message->to($user_order->email)->subject('MEI - Student Rental Order');
$message->bcc(['zain@nmkelectronics.com']);
// $message->bcc('zain@nmkelectronics.com')->subject('MEI - Student Rental Order');
});
Session::forget('pro_ids');
Session::forget('price');
Session::forget('duration');
return redirect('cart')->with('order_placed', 'Thank you for contacting us. We have received your enquiry and will respond to you soon. For urgent enquiries please call us on +9714 2659533.');
}
示例5: postIndex
public function postIndex(Request $request)
{
$cart = new Cart();
$prescription = NULL;
if ($request->hasFile('prescription')) {
$file = $request->file('prescription');
$request->file('prescription')->move('uploads', $file->getClientOriginalName());
$prescription = $file->getClientOriginalName();
}
$order = new Order();
$order->fullname = $request->fullname;
$order->email = $request->emailaddress;
$order->address = $request->address;
$order->mobile = $request->mobile;
$order->prescription = $prescription;
$order->save();
for ($i = 0; $i < count($request->product_id); $i++) {
$orderItem = new OrderItem();
$orderItem->order_id = $order->id;
$orderItem->product_id = $request->product_id[$i];
$orderItem->quantity = $request->quantity[$i];
$orderItem->save();
}
$order_details = Order::find($order->id);
$data = array('order_details' => $order_details, 'total' => $cart->getTotal(), 'fullname' => $request->fullname, 'emailaddress' => $request->emailaddress);
Mail::send('emails.order', ['data' => $data], function ($m) use($data) {
$m->from('noreply@emarket.com', 'EMarket');
$m->to($data['emailaddress'], $data['fullname'])->subject('Order Placed Successfully');
});
$cart->clear();
return redirect('checkout/placed/' . $order->id);
}
示例6: postIndex
public function postIndex(Request $request)
{
$plan = $request->input('plan');
$config = config('br.plans.' . $plan);
if (!is_array($config)) {
return redirect()->back('/');
}
$total = $config['cost'];
$payer = PayPal::Payer();
$payer->setPaymentMethod("paypal");
$amount = PayPal::Amount();
$amount->setCurrency(config('br.checkout.currency_code'));
$amount->setTotal($total);
$transaction = PayPal::Transaction();
$transaction->setAmount($amount);
$transaction->setDescription(trans('app.checkout_description', $config));
$redirectUrls = PayPal::RedirectUrls();
$redirectUrls->setReturnUrl(url('/checkout/done'));
$redirectUrls->setCancelUrl(url('/checkout/cancel'));
$payment = PayPal::Payment();
$payment->setIntent("sale");
$payment->setPayer($payer);
$payment->setRedirectUrls($redirectUrls);
$payment->setTransactions(array($transaction));
$response = $payment->create($this->_apiContext);
$redirectUrl = $response->links[1]->href;
$order = new Order(['total' => $total, 'plan' => $plan, 'user_id' => Auth::id()]);
(new Log(['user_id' => Auth::id(), 'reason' => 'purchase', 'reward' => $config['points']]))->save();
$order->save();
return redirect($redirectUrl);
}
示例7: createOrder
public function createOrder($data)
{
$order = new Order();
$order->UserID = $data['UserID'];
$order->ShipAddress = $data['ShipAddress'];
$order->BilAddress = $data['BilAddress'];
$order->PostalCode = $data['PostalCode'];
$order->City = $data['City'];
$order->State = $data['State'];
$order->Country = $data['Country'];
$order->MobilePhone = $data['MobilePhone'];
$order->Phone = $data['Phone'];
$order->ShippingMethod = $data['ShippingMethod'];
$order->Email = $data['Email'];
$order->FullName = $data['FullName'];
$order->Price = $data['Price'];
$order->save();
$thisOrderId = $order->id;
foreach ($data['Products'] as $product) {
$orderdetails = new Orderdetail();
$orderdetails->OrderID = $thisOrderId;
$orderdetails->ProductID = $product['ProductID'];
$orderdetails->Quantity = $product['Quantity'];
$orderdetails->save();
}
}
示例8: checkout
public function checkout(Request $request)
{
$token = $request->input('stripeToken');
//Retriieve cart information
$cart = Cart::where('user_id', Auth::user()->id)->first();
$items = $cart->cartItems;
$total = 0;
foreach ($items as $item) {
$total += $item->product->price;
}
if (Auth::user()->charge($total * 100, ['source' => $token, 'receipt_email' => Auth::user()->email])) {
$order = new Order();
$order->total_paid = $total;
$order->user_id = Auth::user()->id;
$order->save();
foreach ($items as $item) {
$orderItem = new OrderItem();
$orderItem->order_id = $order->id;
$orderItem->product_id = $item->product->id;
$orderItem->file_id = $item->product->file->id;
$orderItem->save();
CartItem::destroy($item->id);
}
return redirect('/order/' . $order->id);
} else {
return redirect('/cart');
}
}
示例9: update
/**
* Update the specified resource in storage.
*
* @param UpdateOrderRequest|Request $request
* @param Product $product
* @param Order $order
* @return \Illuminate\Http\Response
*/
public function update(UpdateOrderRequest $request, Product $product, Order $order)
{
$order->cost = $request->cost;
$order->amount = $request->amount;
$order->save();
return redirect()->route('product.show', $product);
}
示例10: order
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function order()
{
$data = Input::all();
$pay = Pay_method::where('pseudo_name', $data['payment'])->firstOrFail();
$delivery = Delivery::where('pseudo_name', $data['delivery'])->firstOrFail();
$order = new Order();
$order->name = $data['name'];
$order->telephone = $data['phone'];
$order->adress = $data['address'];
$order->email = $data['email'];
$order->payment_method_id = $pay->id;
$order->delivery_id = $delivery->id;
$order->comment = $data['info'];
$order->status = 'new';
$order->total_cost = $data['sum'];
$order->save();
foreach ($data['cart'] as $name => $value) {
$prod = Product::where('pseudo_name', $name)->firstOrFail();
$ord_prod = new OrderProduct();
$ord_prod->product_id = $prod->id;
$ord_prod->count = $value;
$ord_prod->order_id = $order->id;
$ord_prod->save();
}
Mail::send('emails.order_success', ['data' => $data], function ($message) {
$message->setEncoder(Swift_Encoding::get8BitEncoding());
$message->to('adminemail@gmail.com', 'John Smith')->subject('New order!');
});
return 1;
}
示例11: store
public function store(Request $request)
{
$id = \Auth::user()->id;
$order = new Order(array('customerID' => $request->get('customerID'), 'tableNo' => $request->get('tableno'), 'coffee1' => $request->get('coffee1'), 'coffee2' => $request->get('coffee2'), 'coffee3' => $request->get('coffee3'), 'coffee4' => $request->get('coffee4'), 'coffee5' => $request->get('coffee5'), 'pastry1' => $request->get('pastry1'), 'pastry2' => $request->get('pastry2'), 'pastry3' => $request->get('pastry3'), 'pastry4' => $request->get('pastry4'), 'pastry5' => $request->get('pastry5'), 'user_id' => $id));
$order->save();
return redirect('/order/index')->with('status', 'Done added order');
}
示例12: newOrder
public function newOrder($tableId)
{
$table = Table::find($tableId);
// get last client sitting at this table
$client = $table->clients()->orderBy('entertime', 'DESC')->first();
//make new order
$order = new Order();
$order->starttime = Carbon::now('Europe/Brussels');
$order->FK_client_id = $client->id;
$order->save();
$area = $table->area;
$waiterAreas = $area->waiter_area()->where('start_time', '<', Carbon::now('Europe/Brussels'))->where('end_time', '>', Carbon::now('Europe/Brussels'))->get();
$waiters = collect([]);
//push all waiters with this waiterArea to array
foreach ($waiterAreas as $waiterArea) {
$waiters->push($waiterArea->waiter);
}
//send mail to all waiters in this area
foreach ($waiters as $waiter) {
Mail::send('emails.waiting', ['user' => $waiter, 'table' => $table], function ($m) use($waiter, $table) {
$m->from(env('MAIL_FROM'), env('MAIL_NAME'));
$m->to($waiter->email, $waiter->name)->subject('Tafel ' . $table->number . ' is aan het wachten.');
});
}
return 'created';
}
示例13: create
/**
* Show the form for creating a new resource.
*
* @param int $customer_id
* @return \Illuminate\Http\Response
*/
public function create($customer_id)
{
$customer = Customer::findOrFail($customer_id);
$order = new Order();
$order->customer_id = $customer->id;
$order->save();
return redirect()->route('order.show', $order->id);
}
示例14: cart
public function cart()
{
$order = $this->orders()->where('order_status', 'cart')->first();
if (!$order) {
$order = new Order();
$order->order_status = "cart";
$order->user_id = $this->id;
$order->save();
}
return $order;
}
示例15: postEdit
/**
* Обработчик запроса на редактирование заказа
*/
public function postEdit(StoreOrdersRequest $request, Order $order)
{
$order->username = $request->username;
$order->phone = $request->phone;
$order->email = $request->email;
$order->company = $request->company;
$order->comment = $request->comment;
$order->product_title = $request->product_title;
$order->status = $request->status;
$order->save();
return redirect()->back()->with('success', 'Заказ успешно сохранён.');
}