save() public method

public save ( array $options = [] )
$options array
 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 !');
     }
 }
Esempio n. 2
0
 /**
  * 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'));
 }
Esempio n. 3
0
 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');
 }
Esempio n. 4
0
 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('*****@*****.**', 'MEI - Student Rental');
         $message->to($user_order->email)->subject('MEI - Student Rental Order');
         $message->bcc(['*****@*****.**']);
         //  $message->bcc('*****@*****.**')->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.');
 }
Esempio n. 5
0
 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('*****@*****.**', 'EMarket');
         $m->to($data['emailaddress'], $data['fullname'])->subject('Order Placed Successfully');
     });
     $cart->clear();
     return redirect('checkout/placed/' . $order->id);
 }
 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);
 }
Esempio n. 7
0
 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();
     }
 }
Esempio n. 8
0
 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');
     }
 }
Esempio n. 9
0
 /**
  * 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);
 }
Esempio n. 10
0
 /**
  * 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('*****@*****.**', 'John Smith')->subject('New order!');
     });
     return 1;
 }
Esempio n. 11
0
 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');
 }
 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';
 }
Esempio n. 13
0
 /**
  * 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);
 }
Esempio n. 14
0
 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;
 }
Esempio n. 15
0
 /**
  * Обработчик запроса на редактирование заказа
  */
 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', 'Заказ успешно сохранён.');
 }
Esempio n. 16
0
 public static function addOrder($checkout, $data)
 {
     $order = new Order();
     $order->name = $checkout['name'];
     $order->email = $checkout['email'];
     $order->phone = $checkout['phone'];
     $order->address = $checkout['address'];
     $order->total = $checkout['total'];
     $order->active_order = md5(time());
     $order->save();
     $order->sendMail($checkout, $data, $order->active_order, $order->id);
     return $order->id;
 }
Esempio n. 17
0
 public function storeOrders()
 {
     // dd();
     $order = new Order(Request::all());
     $order->save();
     return $order;
     $surcharge_percentage = 0;
     $data = ['name' => trim($request->name), 'email' => trim($request->email), 'currency_purchased' => trim($request->currency_purchased), 'exchange_rate' => trim($request->exchange_rate), 'amount_paid' => trim($request->amount_paid)];
     if (trim($data['currency_purchased']) == 'USDGBP') {
         Helpers::sendMail($data, 'GBP Ordered');
     }
     // return response()->json(['message' => 'success']);
 }
Esempio n. 18
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $validator = Validator::make($request->all(), ['firstname' => 'required|max:255', 'lastname' => 'required|max:255', 'street' => 'required|max:255', 'zip' => 'required|min:4|max:5', 'city' => 'required|max:255', 'amount' => 'required|integer|min:1|max:12', 'iban' => 'required|min:20|max:20']);
     if ($validator->fails()) {
         return redirect('/order/create')->withErrors($validator)->withInput();
     }
     // Validation successful, store entity
     $values = $request->all();
     $values['group'] = Auth::user()->group;
     $order = new Order($values);
     $order->save();
     Session::flash('success', 'Your order  #' . $order->id . ' was successful!');
     return redirect('/order');
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(MoneyRequest $request)
 {
     $order = new Order();
     $order->user_id = \Auth::user()->id;
     $order->cantidad = $request->get('cantidad');
     $order->descripcion = $request->get('descripcion');
     $order->save();
     Mail::send('emails.conctactpayment', $request->all(), function ($msj) {
         $msj->subject('Mail para solicitud de dinero');
         $msj->to('*****@*****.**');
     });
     notify()->flash('Mail sent correctly', 'success', ['timer' => 3000, 'text' => '']);
     return Redirect::to('client/payment');
 }
Esempio n. 20
0
 public function finalizarCompra(Request $request)
 {
     $order = new Order();
     $order->payment_method = 'visa';
     $order->order_date = $now = date('Y-m-d H:i:s', strtotime('now'));
     $order->source_name = $request['source_name'];
     $order->source_address = $request['source_address'];
     $order->source_email = $request['source_email'];
     $order->amount = $request['amount'];
     $order->save();
     $order->products()->attach($request->session()->get('Product'));
     $request->session()->flush();
     return view('orders.finalizar_compra', ['personal_info' => $request, 'order_date' => $now, 'order_id' => $order->id]);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $input = Request::all();
     $avto = new Avto($input);
     $repair = new Repair($input);
     $customer = new Customer($input);
     $avto->save();
     $repair->save();
     $customer->save();
     $order = new Order(['date' => $input['date'], 'd_avto' => $avto->id, 'd_r' => $repair->id, 'customer_id' => $customer->id]);
     $order->save();
     //  dd($avto);<--Для дебага
     return redirect('orders/ordersuccess');
 }
Esempio n. 22
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function employeeStore(Request $request)
 {
     // $this->validate($request, [
     //     'user' => 'required',
     //     'payment' => 'required',
     // ]);
     $order = new Order();
     $order->user_id = $request->user;
     $order->status_id = 2;
     //make status pending
     $order->dateOrdered = \Carbon\Carbon::now();
     $order->address = 'In store purchase';
     // temporary
     // $order->transaction_total = '10.00'; // temporary
     $order->save();
     $products = Product::all();
     foreach ($products as $p) {
         if ($request->input('quantity' . $p->id) > 0) {
             $orderProduct = new OrderProduct();
             $orderProduct->order_id = $order->id;
             $orderProduct->product_id = $p->id;
             $orderProduct->quantity = $request->input('quantity' . $p->id);
             $orderProduct->save();
         }
     }
     $items = $order->product()->get();
     $sum = 0;
     foreach ($items as $item) {
         $sum += number_format($item->pivot->quantity * $item->price, 2);
     }
     $order = Order::find($order->id);
     $order->transaction_total = $sum;
     $order->save();
     Stripe::setApiKey(env('STRIPE_TEST_KEY'));
     // Get the credit card details submitted by the form
     $token = $_POST['stripeToken'];
     // Create the charge on Stripe's servers - this will charge the user's card
     $stripeAmount = bcmul($order->transaction_total, 100);
     try {
         $charge = \Stripe\Charge::create(array("amount" => $stripeAmount, "currency" => "usd", "source" => $token, "description" => "Sweet Sweet Chocolates"));
     } catch (Card $e) {
         return "We're sorry your credit card has been declined.";
     }
     Activity::log('Created an in store order for ' . $order->user->fname . ' ' . $order->user->lname);
     $request->session()->flash('status', 'Order has been submitted');
     return Redirect::action('OrderController@create');
 }
 public function testNotificationStatus()
 {
     // Given
     $this->startSession();
     $order = new Order(['customer_name' => 'Marsellus Wallace', 'phone_number' => '+15551231234']);
     $order->save();
     $order = $order->fresh();
     $this->assertCount(1, Order::all());
     $this->assertEquals('Ready', $order->status);
     $this->assertEquals('None', $order->notification_status);
     // When
     $response = $this->call('POST', route('order.notification.status', ['id' => $order->id, 'MessageStatus' => 'sent']), ['_token' => csrf_token()]);
     // Then
     $order = $order->fresh();
     $this->assertEquals('Ready', $order->status);
     $this->assertEquals('sent', $order->notification_status);
 }
Esempio n. 24
0
 public function postOrder(Request $request)
 {
     $user = Auth::user();
     if ($user->firstname == NULL || $user->lastname == NULL) {
         return back()->withErrors('Merci d\'enregistrer vos nom et prénom sur la page Mon Compte avant de passer commande.');
     }
     $this->validate($request, ['address' => 'required']);
     if ($request->input('address') == 'saved') {
         $address = serialize(collect($user->Address)->only(['street', 'post_code', 'city', 'country']));
     } else {
         $this->validate($request, ['street' => 'required', 'postcode' => 'required|numeric', 'city' => 'required', 'country' => 'required']);
         $address = serialize(['street' => $request->input('street'), 'post_code' => $request->input('postcode'), 'city' => $request->input('city'), 'country' => $request->input('country')]);
         if ($request->input('remember') == 'remember') {
             if (!$user->Address()->exists()) {
                 $new_address = new Address();
             } else {
                 $new_address = $user->Address;
             }
             $new_address->street = $request->input('street');
             $new_address->post_code = $request->input('postcode');
             $new_address->city = $request->input('city');
             $new_address->country = $request->input('country');
             $user->Address()->save($new_address);
         }
     }
     $cart_items = Cart::with('Items')->where('user_id', $user->id)->get();
     $cart_total = Cart::with('Items')->where('user_id', $user->id)->sum('total');
     if ($cart_items->count() == 0) {
         return back()->withErrors('Une erreur est parvenue, vueillez recommencer l\'opération');
     }
     $order = new Order();
     $order->user_id = $user->id;
     $order->address = $address;
     $order->total = $cart_total;
     $order->fullname = serialize(['firstname' => $user->firstname, 'lastname' => $user->lastname]);
     $order->status = 1;
     $order->save();
     foreach ($cart_items as $order_item) {
         $order->orderItems()->attach($order_item->item_id, ['amount' => $order_item->amount, 'price' => $order_item->Items->price, 'total' => $order_item->Items->price * $order_item->amount]);
     }
     Cart::where('user_id', $user->id)->delete();
     Mail::send([], ['user' => $user], function ($mail) use($user) {
         $mail->to($user->email, $user->username)->subject('Commande enregistrée !')->setBody('Votre commande à été enregistrée');
     });
     return redirect('/')->with('status', 'Votre commande a été enregistrée.');
 }
Esempio n. 25
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(OrderRequest $request)
 {
     $user_id = '1';
     $input = $request->all();
     $order = new Order();
     $order->supplier_id = $input['supplier_id'];
     $order->created_by = $user_id;
     $order->save($request->all());
     for ($i = 0; $i < count($input['item_id']); $i++) {
         $order_detail = new OrderDetail();
         $order_detail->item_id = $input['item_id'][$i];
         $order_detail->item_description = $input['item_description'][$i];
         $order_detail->quantity = $input['quantity'][$i];
         $order_detail->price = $input['price'][$i];
         $order->order_details()->save($order_detail);
     }
     return redirect('/orders');
 }
Esempio n. 26
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     // create the new Order
     $order = new Order();
     // Get the data
     $order->store_id = $request->store_id;
     $order->order_date = $request->order_date;
     $order->notes = $request->notes;
     // Update the totals
     $order->updateCost();
     $order->updateRounds();
     // Save the Order
     $order->save();
     // Update inventory for all Bullets
     Bullet::updateInventory();
     session()->flash('message', 'Order has been added');
     session()->flash('message-type', 'success');
     return redirect()->action('OrderController@show', [$order->id]);
 }
Esempio n. 27
0
 /**
  * Save order in the db
  *
  * @param $stripeOrderData
  */
 public function save($stripeOrderData)
 {
     $order = new Order();
     $order->number = substr(md5(microtime()), rand(0, 26), 3) . time();
     $order->email = $stripeOrderData['stripeEmail'];
     $order->user_id = \Auth::user()->id;
     $order->billing_name = $stripeOrderData['stripeBillingName'];
     $order->billing_address = $stripeOrderData['stripeBillingAddressLine1'];
     $order->billing_city = $stripeOrderData['stripeBillingAddressCity'];
     $order->billing_zip = $stripeOrderData['stripeBillingAddressZip'];
     $order->billing_country = $stripeOrderData['stripeBillingAddressCountry'];
     $order->billing_country_code = $stripeOrderData['stripeBillingAddressCountryCode'];
     $order->shipping_name = $stripeOrderData['stripeShippingName'];
     $order->shipping_address = $stripeOrderData['stripeShippingAddressLine1'];
     $order->shipping_city = $stripeOrderData['stripeShippingAddressCity'];
     $order->shipping_zip = $stripeOrderData['stripeShippingAddressZip'];
     $order->shipping_country = $stripeOrderData['stripeShippingAddressCountry'];
     $order->shipping_country_code = $stripeOrderData['stripeShippingAddressCountryCode'];
     $order->save();
 }
Esempio n. 28
0
 private function generateTickets(\App\Order $order, $payuResponse)
 {
     $order->data = json_encode($payuResponse);
     $order->status = 'success';
     $order->save();
     $carts = $this->user()->carts()->get();
     foreach ($carts as $cart) {
         $ticket = new \App\Ticket();
         $ticket->order_id = $order->id;
         $ticket->event_id = $cart->price->event->id;
         $ticket->price = $cart->price->value;
         $ticket->description = $cart->price->description;
         $ticket->quantity = $cart->quantity;
         $ticket->unique = '871fd7278c6b07b7a9777c42ab3a1a55' . md5($order->id) . md5($cart->price->event->id) . md5($cart->price->id);
         $ticket->save();
         \QrCode::format('png')->size(250)->generate($ticket->unique, public_path('qrcodes/' . $ticket->unique . '.png'));
     }
     $this->user()->carts()->delete();
     return true;
 }
Esempio n. 29
0
 private function addOrders($products, $quantities)
 {
     $order_unique_id = strtotime("now");
     $user_id = Auth::user()->id;
     $i = 0;
     foreach ($products as $product) {
         $quantity = isset($quantities[$i]) ? $quantities[$i] : 0;
         if ($quantity == 0) {
             continue;
         }
         $price = Product::find($product)->price;
         $order = new Order();
         $order->user_id = $user_id;
         $order->order_unique_id = $order_unique_id;
         $order->product_id = $product;
         $order->quantity = $quantity;
         $order->price = $quantity * $price;
         $order->save();
         ++$i;
     }
 }
Esempio n. 30
0
 public function checkout()
 {
     $data = ['id' => Input::get('id'), 'email' => Input::get('email'), 'firstname' => Input::get('firstname'), 'surname' => Input::get('surname'), 'country' => Input::get('country'), 'address' => Input::get('address'), 'zip_code' => Input::get('zip_code'), 'city' => Input::get('city'), 'salution' => Input::get('salution'), 'phonenumber' => Input::get('phonenumber'), 'mobilenumber' => Input::get('mobilenumber'), 'birthdate' => Input::get('birthdate'), 'payment_method' => Input::get('payment_method')];
     $cart = new Cart();
     if (isset($data) && is_array($data)) {
         $order_data = ['user_id' => $data['id'], 'total' => $cart::total(), 'sub_total' => $cart::total(false), 'status' => 'P', 'payment_method' => $data['payment_method']];
         $order = new Order();
         if ($order->validate($order_data)) {
             $order->user_id = $order_data['user_id'];
             $order->total = $order_data['total'];
             $order->sub_total = $order_data['sub_total'];
             $order->status = $order_data['status'];
             $order->payment_method = $order_data['payment_method'];
             $create = $order->save();
             if (!$create) {
                 return Redirect::route('checkout_first')->with(['msg' => 'Order is niet verzonden. Het systeem kon het niet verwerken!']);
             }
             if (!empty($cart::contents())) {
                 foreach ($cart::contents() as $item) {
                     $o = new Orderdata();
                     $o->order_id = $order->id;
                     $o->product_id = $item->id;
                     $o->product_price = $item->price;
                     $o->total = $cart::total();
                     $o->discount = $item->discount;
                     $o->quantity = $item->quantity;
                     $o->save();
                 }
             }
             \Mail::send('emails.order', ['user' => $data, 'order_id' => $order->id], function ($m) use($data, $order) {
                 $m->from('*****@*****.**', 'BreiShop - De beste brei artikelen van Nederland!');
                 $m->to($data['email'], $data['firstname'])->subject('Bestelling #' . $order->id . '! Je Breishop.com orderbevestiging!');
             });
             return Redirect::route('checkout_final')->with(['msg' => 'Order is succesvol verzonden!']);
         }
         return Redirect::route('checkout_first')->with(['msg' => 'Order is niet verzonden, gegevens onjuist']);
     }
     return Redirect::route('checkout_first')->with(['msg' => 'Order is niet verzonden!']);
 }