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 !'); } }
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'; }
/** * 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; }
private function buildOrderFromAlpha($alphaOrder) { $bravoOrder = $this->getBravoOrder($alphaOrder->order_number); $order = new Order(); $order->fill(['order_number' => $alphaOrder->order_number, 'alpha' => $alphaOrder->alpha, 'bravo' => $bravoOrder->bravo]); return $order; }
public function testPayMethodReturnFalse() { $order = new Order(new ProductList()); $mockPaymentMethod = new MockFalseChargePaymentMethod(); $order->setPaymentMethod($mockPaymentMethod); $this->assertFalse($order->pay()); }
public function __construct(Order $order) { if (!$order) { dd('vantar pöntun'); } $this->order = $order; $this->testing = false; if (env('BORGUN_TEST') == true) { $this->site = 'https://test.borgun.is/SecurePay/default.aspx'; $this->testing = true; $this->PaymentGatewayId = '16'; $this->MerchantId = '9275444'; $this->SecretKey = '99887766'; } else { $this->site = 'https://securepay.borgun.is/securepay/default.aspx'; $this->PaymentGatewayId = env('BORGUN_PAYMENTGATEWAYID'); $this->MerchantId = env('BORGUN_MERCHANTID'); $this->SecretKey = env('BORGUN_SECRETKEY'); } $this->ReturnUrlSuccess = \Request::root() . '/payment/borgun/success'; $this->ReturnUrlSuccessServer = \Request::root() . '/payment/borgun/successserver'; $this->ReturnUrlCancel = \Request::root() . '/payment/borgun/cancel'; $this->ReturnUrlError = ''; $this->OrderId = $order->reference; $this->Amount = $order->total(); $this->Currency = 'ISK'; $this->Language = 'IS'; }
/** * Destroy the given order. * * @param Request $request * @param Order $order * @return Response */ public function destroy(Request $request, Order $order) { if (\Auth::id() == $order->user_id) { $order->delete(); } return redirect('/orders'); }
/** * Display a listing of the resource. * * @return Response */ public function index(Request $request, $id) { //总销售金额 $order = new Order(); $_data['sell_total_money'] = $order->newQuery()->whereRaw('`status`>?', array(1))->sum('total_money'); //总订单数 $_data['order_total_cnt'] = $order->newQuery()->count(); //总商品数 $product = new Product(); $_data['product_total_cnt'] = $product->newQuery()->count(); //总用户数 $user = new User(); $_data['user_total_cnt'] = $user->newQuery()->count(); $this->_week_start = $week_start = date("Y-m-d 00:00:00", strtotime("-" . (date("w") - 1) . " days")); //本周销售 $_data['sell_week_money'] = $order->newQuery()->whereRaw('created_at>= ? and `status`>?', array($week_start, 1))->sum('total_money'); //本周订单 $_data['order_week_cnt'] = $order->newQuery()->whereRaw('created_at>= ?', array($week_start))->count(); //本周商品 $_data['product_week_cnt'] = $product->newQuery()->whereRaw('created_at>= ?', array($week_start))->count(); //本周用户 $_data['user_week_cnt'] = $user->newQuery()->whereRaw('created_at>= ?', array($week_start))->count(); $this->_data = $_data; return $this->view('admin.dashboard'); }
function test_an_order_is_discounted_by_a_percentage_when_a_percent_off_coupon_is_applied() { $books = collect([new Book(['price' => 2000]), new Book(['price' => 3000]), new Book(['price' => 4000])]); $coupon = new Coupon(['value' => 30, 'is_percent' => true]); $order = new Order($books); $order->applyCoupon($coupon); $this->assertEquals(6300, $order->total()); }
public function createOrderWithProducts() { $order = new Order(); $product = new Product('Fallout 4', 59); $product2 = new Product('Pillowcase', 7); $order->add($product); $order->add($product2); return $order; }
/** @test */ function an_order_can_determine_the_total_cost_of_all_its_products() { $order = new Order(); $product = new Product('Fallout 4', 59); $product2 = new Product('pillowcase', 7); $order->add($product); $order->add($product2); $this->assertEquals(66, $order->total()); }
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; }
/** * @param Request $request * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ public function store_adres(Request $request) { $order = new Order(); $order->fill($request->all()); $order->email = $request->input('order_email'); if ($request->input('email') && $request->input('password')) { $request->merge(array('name' => $order->Fullname)); $this->postRegister($request); } Session::put("order", $order); return redirect('/shoppingcart/step/2'); }
public function changeStatus(Request $request, Order $order, Product $product, $id) { $input = $request->order_status; if ($input == 4) { $content = $order->find($id)->content; foreach ($content as $item) { $product->restIncrement($item->product_id, $item->quantity); } } $order->changeStatus($id, $input); $status = $order->find($id)->status->title; return redirect()->back()->with('message', "Статус заказа изменен на '{$status}'"); }
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']); }
/** * Display a listing of the resource. * * @return Response */ public function index() { $inv_types = InvType::all(); $inventories = Inventory::all(); $orders = array(); $order = new Order(); for ($i = 0; $i < 6; $i++) { $orders[$i] = $order->get_order_by_table($i + 1); } $page_title = 'Table Orders'; $date = date('Y-m-d'); return view('test', compact('page_title', 'date', 'inv_types', 'inventories', 'orders')); }
public function data(Request $request) { $order = new Order(); $builder = $order->newQuery()->with(['order_express'])->join('order_expresses', 'order_expresses.id', '=', 'orders.id', 'INNER')->whereIn('order_expresses.sid', $this->stores_ids); $_builder = clone $builder; $total = $_builder->count(); unset($_builder); $data = $this->_getData($request, $builder); //dd($data); $data['recordsTotal'] = $total; $data['recordsFiltered'] = $data['total']; return $this->success('', FALSE, $data); }
/** * 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'); }
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(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'); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $orders = Order::all(); foreach ($orders as $order) { echo $order->name . " Ordered by: " . $order->customer->name . "<br/>"; } }
public function makeOrder(Request $request) { $validator = $this->validator($request->all()); if (!isset(\Auth::user()->name)) { if ($validator->fails()) { return redirect('order/save')->withErrors($validator)->withInput(); } } $input = $request->all(); $cartCollection = Cart::getContent(); $products = $cartCollection->toArray(); $productId = array_keys($products); if (isset(\Auth::user()->name)) { $authUser = \Auth::user(); $orderSave = Order::create(['telephone' => $authUser->telephone, 'user_name' => $authUser->name, 'email' => $authUser->email, 'adress' => $authUser->adress, 'town' => $authUser->town, 'comment' => $input['comment']]); } else { $orderSave = Order::create(['telephone' => $input['telephone'], 'user_name' => $input['name'], 'email' => $input['email'], 'adress' => $input['adress'], 'town' => $input['town'], 'comment' => $input['comment']]); } $order = Order::find($orderSave->id); $order->product()->attach($productId); foreach ($productId as $rm) { Cart::remove($rm); } return redirect(LaravelLocalization::setLocale() . "/")->with('msg', 'Направихте успешна поръчка. Ще се свържем скоро.'); }
/** * Handle the event. * * @param MadeCheckout $event * @return void */ public function handle(MadeCheckout $event) { $user = $event->user; $checkout = $event->checkout; $orders = Order::with('product')->where('checkout_id', $checkout->id)->get(); $admin = Sentinel::findRoleBySlug('admin'); $admins = $admin->users()->get(); $admin_emails = []; foreach ($admins as $admin) { array_push($admin_emails, $admin->email); } $data = ['checkout' => $checkout, 'orders' => $orders, 'user' => $user]; //dd($data); Mail::send('email.orderconfirmation', $data, function ($message) use($user) { $message->from('*****@*****.**', $name = "Trolleyin"); $message->subject('Trolleyin.com Order Confirmation'); $message->to($user->email); }); foreach ($admin_emails as $email) { Mail::send('email.admin.orderconfirmation', $data, function ($message) use($email) { $message->from('*****@*****.**'); $message->subject('New Order Placed'); $message->to($email); }); } }
public function Chart() { $yesterday = Carbon::now(); $start = $yesterday->copy()->addDays(-7); $end = $yesterday->copy(); // for query $startBetween = $start->format('Y-m-d'); $endBetween = $end->format('Y-m-d'); $dates = []; while ($start->lte($end)) { $dates[] = $start->copy(); $start->addDay(); } $dates = collect($dates)->forPage(1, 7); $reports = \App\Order::ReportGroup("(orders.`tanggal` BETWEEN '{$startBetween}' AND '{$endBetween}')", "GROUP BY tanggal"); $reports = ConvertRawQueryToArray($reports); $dataLastWeek = []; $dataLabelLastWeek = []; foreach ($dates as $date) { $idx = array_search($date->format("Y-m-d"), array_column($reports, "tanggal")); $val = 0; if (false !== $idx) { $d = $reports[$idx]; $val = $d['jumlah']; } $dataLabelLastWeek[] = $date->format('d M Y'); $dataLastWeek[] = $val; } return ['label' => $dataLabelLastWeek, 'data' => $dataLastWeek]; }
/** * Execute the console command. * * @return mixed */ public function fire() { $days_to_wait = Config::get('store.days_to_remind'); //\DB::enableQueryLog(); $this->info("Checks If there are orders to be rated ({$days_to_wait} Days Old)"); //Checks all closed orders that has not been rated nor mail has been sent and where updated 5 days ago //and the mails has not been sent yet $orders = Order::where('rate', null)->where('status', 'closed')->where('rate_mail_sent', false)->where('updated_at', '<', Carbon::now()->subDays($days_to_wait))->get(); //$this->info(print_r(\DB::getQueryLog())); $this->info("Orders That need mail: " . $orders->count()); foreach ($orders as $order) { $this->info("Order: " . $order->id . ' Needs to be rated, and mail has not been sent'); $buyer = User::find($order->user_id); if ($buyer) { $email = $buyer->email; $mail_subject = trans('email.cron_emails.remind_rate_order_subject'); $data = ['email_message' => $mail_subject, 'email' => $email, 'subject' => $mail_subject, 'order_id' => $order->id]; Mail::queue('emails.cron.rate_order', $data, function ($message) use($data) { $message->to($data['email'])->subject($data['subject']); }); $order->rate_mail_sent = true; $order->save(); } } }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index(Request $request) { //Get the Number of Orders $count = Order::todaysOrders(); JavaScript::put(['foo' => 'bar', 'user' => User::first(), 'age' => 29]); return view('pages.index', ['count' => $count]); }
public function destroy($id) { $order = Order::findOrFail(id); $deleted = $order->delete(); $message = $deleted ? "Pedido eliminado" : "Error al intentar eliminar el pedido"; return redirect()->route('admin.order.index')->with('message', $message); }
/** * 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(), ['accountname' => 'required|max:255', 'iban' => 'required|min:20|max:20', 'subject' => 'required|max:255', 'sum' => 'required', 'order_id' => 'required|integer|min:1']); $values = $request->all(); $values = array_map('trim', $values); //remove leading and trailing whitespaces on all values $values['group'] = Auth::user()->group; //try calculating the sum from string try { $calculator = new \NXP\MathExecutor(); $values['sum'] = $calculator->execute($values['sum']); } catch (Exception $e) { Log::Info('Input: "' . $values['sum'] . '" has failed to evaluate'); } // Check whether the order exists and is actually owned by the given group $order = Order::where('id', $values['order_id'])->where('group', $values['group'])->firstOrFail(); if ($validator->fails()) { // Return JSON response with 422 HTTP status code return $validator->errors()->all(); } // Validation successful, store entity $payment = new Payment($values); $payment->save(); return $payment; }
/** * Return all the orders with their products and price/amount at given time * * @return \Illuminate\Database\Eloquent\Collection|static[] */ public function index() { return Order::with(['products' => function ($query) { $query->select(['id', 'name', 'price', 'pivot.price', 'pivot.amount']); $query->orderBy('sort'); }])->get(); }
public function deleteOrder(Request $request) { $order_id = \StringHelper::filterString($request->input('order_id')); $deletedRows = Order::where('id', $order_id)->delete(); $catRow = OrderDetail::where('order_id', $order_id)->delete(); return Redirect::back()->with('message', 'Success'); }