/** * 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; }
public function BrojUserPorudzbina() { $usersId = Auth::user()->id; // $porudzbine =Order::get(); $userPosts = Order::where('user_id', $usersId)->count(); $iznos = Order::where('user_id', $usersId)->latest('created_at')->take(1)->first(); // user porudzbine evidencija // $usersId2=Auth::user()->id; // // // $porudzbine2 = DB::table('order'); // // $osnovnaPorudzbina= $porudzbine2->where('user_id', $usersId2)->latest('created_at')->take(1)->pluck('created_at'); //// //// //// // $time = date('H:i:s', strtotime($osnovnaPorudzbina)); //// //// kreirano vreme // $date=Carbon::createFromFormat('H:i:s', $time); // $vreme= $date->addMinutes(30); //// $vreme=date('H:i:s', strtotime($vreme)); // //// vreme posle 30 minuta // // $trenutno= Carbon::now(); // print gmdate("H:i:s", $trenutno->diffInSeconds($vreme)); return view('articles.glavni', compact('userPosts', 'iznos')); }
public function update(Request $request, $id) { // $data = $request->all(); Order::where('id', $id)->update(array('status' => $data['status'], 'shipped_date' => $data['shipped_date'])); return Redirect::back(); }
/** * Display a listing of the resource. * * @return Response */ public function index() { // $menuOptions = [0 => ["data-letters" => "", "id" => "home", "text" => "Home", "href" => "/"]]; if (Auth::check()) { $user = Auth::user(); $verifyAdmin = Admin::find($user->id); if (isset($verifyAdmin->id)) { $users = User::all(); $fabrics = Fabric::all(); $data = array("latestOrders" => Order::getOrders(0), "latestUsers" => User::where("confirmed", "=", "0")->orderBy("created_at", "")->take(5)->get(), "user" => $user, "users" => $users, "fabrics" => $fabrics, "orders" => Order::getOrders(0), "confirmed-users" => User::where("confirmed", "=", "1")->orderBy("created_at", "")->take(5)->get(), "admin" => true); /*Session::put('paginate', [ "confirmed-users" => 5, "not-confirmed-users" => 5, "not-confirmed-orders" => 5, "confirmed-orders" => 5 ]);*/ return view("panel.admin-panel")->with("data", $data)->with("user", $user); } else { $stats = ["orders" => Order::where("user_id", "=", $user->id)->count(), "unconfirmed" => Order::where("user_id", "=", $user->id)->where("status", "=", "not-confirmed")->count(), "confirmed" => Order::where("user_id", "=", $user->id)->where("status", "=", "confirmed")->count(), "latest" => Order::where("user_id", "=", $user->id)->max("created_at")]; //dd(Order::getOrdersUser($user->id)); $data = array("orders" => Order::getOrdersUser($user->id, 0), "stats" => $stats, "fabrics" => Fabric::all(), "admin" => false); /*Session::put('paginate', [ "confirmed-orders" => 5, "not-confirmed-orders" => 5, ]);*/ return view("panel.normal-panel")->with("user", $user)->with("data", $data); } } else { return redirect("/")->with("menuOptions", $menuOptions); } }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function getIndex(Request $request) { // Get all the orders created by the current logged in users // Sort in descending order by id $orders = \App\Order::where('user_id', '=', \Auth::id())->orderBy('id', 'DESC')->get(); return view('orders.index')->with('orders', $orders); }
/** * 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 Response */ public function index() { $studentid = Auth::user()->studentid; $orders = Order::where('userid', '=', $studentid)->get(); $applications = Application::where('studentid', '=', $studentid)->get(); return view('infohome', ['orders' => $orders, 'applications' => $applications]); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function orders() { $begin = new DateTime(\Carbon\Carbon::now()->subDays(7)); $end = new DateTime(\Carbon\Carbon::now()); $interval = DateInterval::createFromDateString('1 day'); $period = new DatePeriod($begin, $interval, $end); // $orderCount = []; // foreach ($period as $p ){ // $dt = $p->format( "Y-m-d" ); // $oc = Order::where('dateOrdered', $dt)->where('status_id', '>', 1)->count(); // $orderCount[] = $oc; // }; $orderCount = []; for ($i = 7; $i >= 0; $i--) { $oc = Order::where('dateOrdered', \Carbon\Carbon::now()->subDays($i)->format('Y-m-d'))->count(); $orderCount[] = $oc; } $sumTransactions = []; for ($i = 7; $i >= 0; $i--) { $sum = Order::where('dateOrdered', \Carbon\Carbon::now()->subDays($i)->format('Y-m-d'))->sum('transaction_total'); $sumTransactions[] = $sum; } $dates = []; foreach ($period as $p) { $dt = $p->format("Y-m-d"); $dates[] = $dt; } return view('metrics.orders', ['dates' => $dates, 'orderCount' => $orderCount, 'sumTransactions' => $sumTransactions]); }
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'); }
/** * 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(), ['order_id' => 'required|integer|min:1', 'vorname' => 'required|max:255', 'nachname' => 'required|max:255', 'strasse' => 'required|max:255', 'PLZ' => 'required|min:4|max:5', 'stadt' => 'required|max:255']); if ($validator->fails()) { // Return JSON response with 422 HTTP status code return $validator->errors()->all(); } $values = $request->all(); $values = array_map('trim', $values); //remove leading and trailing whitespaces on all values $values['group'] = Auth::user()->group; // 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(); unset($values['order_id']); // Validation successfull, let's check if we already have a customer with the same namespace $customer = Customer::where('vorname', $values['vorname'])->where('nachname', $values['nachname'])->where('strasse', $values['strasse'])->where('PLZ', $values['PLZ'])->where('stadt', $values['stadt'])->where('group', $values['group'])->first(); Log::Info(print_r($customer, true)); // if this is a new customer, we create it first if (is_null($customer)) { //|| $customer->isEmpty() $customer = new Customer($values); $customer->save(); } $existing_associations = $order->customer()->lists('id'); // check if the relation between order and customer is already established if (!in_array($customer->id, array_values($existing_associations->toArray()))) { // link the customer to the order $order->customer()->attach($customer->id); } // Return customer object return $customer; }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if (!$request->session()->has('order_id')) { $guest = new User(); $guest->is_guest = true; $guest->name = 'Gast'; if ($guest->save()) { $guestOrder = Order::create(['user_id' => $guest->id, 'status' => 0, 'city_id' => $request->session()->get('selectedCity')['id']]); $request->session()->put('user_id', $guest->id); $request->session()->put('order_id', $guestOrder->id); } else { abort(500); } } elseif (Auth::check()) { $databaseOrderID = Order::where('user_id', '=', Auth::id())->where('status', '=', 0)->first(); $sessionOrderID = $request->session()->get('order_id'); if (!count($databaseOrderID)) { $userOrder = Order::create(['user_id' => Auth::id(), 'status' => 0, 'city_id' => $request->session()->get('selectedCity')['id']]); $this->mergeOrders($userOrder->id, $sessionOrderID, $request); } $databaseOrderID = Order::where('user_id', '=', Auth::id())->first(); $sessionOrderID = $request->session()->get('order_id'); if ($databaseOrderID->id != $sessionOrderID) { $this->mergeOrders($databaseOrderID->id, $sessionOrderID, $request); } } return $next($request); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $orders = Order::where('status', '=', '0')->get(); $pageData = self::orderPageData('pending', 1, 0, 1, 1); $pageData['table'] = $orders; return view('panel.orders', $pageData); }
public function purchasedCards(Request $request) { $new_purchase = $request->session()->get('card_purchased', false); $cards = Order::where('user_id', $this->user->id)->get(); $cart_items = $this->cart->totalItems(); return view('user.purchased_cards')->with(compact('cards', 'cart_items', 'new_purchase')); }
public function submitOrder(Request $request) { $this->validate($request, ['merchandiser_id' => 'required|integer', 'trade_no' => 'required|max:255', 'subject' => 'required|max:255', 'amount' => 'required|numeric', 'returnUrl' => 'required|url', 'notifyUrl' => 'required|url', 'items' => 'array']); $data = $request->all(); $merch = Merchandiser::where('status', 'alive')->findOrFail($data['merchandiser_id']); if ($this->verify($data, $merch['pubkey'])) { $order = Order::where('merchandiser_id', $merch['id'])->where('trade_no', $data['trade_no'])->first(); if (empty($order)) { if (parse_url($data['returnUrl'], PHP_URL_HOST) != $merch['domain'] || parse_url($data['notifyUrl'], PHP_URL_HOST) != $merch['domain']) { return $this->jsonFormat(null, 'Your URL must belongs to domain "' . $merch['domain'] . '"', '400'); } $order = Order::create(['merchandiser_id' => $data['merchandiser_id'], 'trade_no' => $data['trade_no'], 'subject' => $data['subject'], 'amount' => $data['amount'], 'items' => serialize($data['items']), 'returnUrl' => $data['returnUrl'], 'notifyUrl' => $data['notifyUrl']]); $order->items = unserialize($order->items); return $this->jsonFormat($order); } elseif ($order->status == 'pending') { $order->update(['subject' => $data['subject'], 'amount' => $data['amount'], 'items' => serialize($data['items'])]); $order->items = unserialize($order->items); return $this->jsonFormat($order); } else { return $this->jsonFormat(null, 'trade_no already exsits', '409'); } } else { return $this->jsonFormat(null, 'Signature Invalid or timestamp expired', '403'); } }
/** * Display a listing of client orders. * * @return Response */ public function index() { $user = \Auth::user(); $client = $user->client; $allOrders = Order::where('client_id', '=', $client->id)->orderBy('created_at', 'DESC')->get(); return view('clients.orders')->with('allOrders', $allOrders); }
public function checkout() { $start_date = Carbon\Carbon::today()->format('Y-m-d'); $user_address = Order::where('id', '=', Auth::user()->id)->select('address')->first(); $items = Cart::content(); $total = Cart::total(); return view('cart/checkout', compact('items', 'total', 'start_date', 'user_address')); }
public function calculatePrice() { $price = 0; foreach (explode("|%", $this->order) as $value) { $price += \App\Order::where('slug', $value)->first()->price; } return $price; }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { $order = Order::where('id', $id)->with('user', 'products')->firstOrFail(); foreach ($order->products as $product) { $productQt = Product::find($product->id)->join('order_product', 'products.id', '=', 'order_product.product_id')->where('order_product.order_id', '=', $id)->get(); } return view('admin.order.details', compact('order', 'productQt')); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $search = \Request::get('search'); //<-- we use global request to get the param of URI // $orders = Order::where('id', 'like', '%' . $search . '%')->where('status', '<>', 'done')->orderBy('id')->paginate(20); // $orders = Order::all(); return view('order.list', array('orders' => $orders)); }
public function delivered_orders() { $orders = Order::where('money', '>', 0)->orderBy('created_at', 'desc')->paginate(50); $this->data['current_tab'] = 40; $this->data['orders'] = $orders; $this->data['last_page'] = $orders->lastPage(); $this->data['current_page'] = $orders->currentPage(); return view('manage.order.delivered_orders', $this->data); }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { if (Auth::user()->admin == 1) { $order = Order::findOrFail($id); } else { $order = Order::where('group', Auth::user()->group)->where('id', $id)->firstOrFail(); } return view('order.show', ['order' => $order]); }
public function show($id) { $order = Order::where('id', '=', $id)->with('OrderItems')->first(); if (!Auth::user()->admin == "1" || !Auth::user()->id == $order->user_id) { return redirect('/dashboard'); } $user = User::where('id', '=', $order->user_id)->first(); return view('orders.show', compact('order', 'user')); }
public function index() { View::share(['sideBar' => NavigatorHelper::getSideBarBE()]); $status = Status_orders::all(['name', 'id'])->toArray(); $newProduct = Cd::whereIn('public_date', [Carbon::today(), Carbon::today()->subDay(3)])->count(); $newArtist = Artist::whereIn('created_at', [Carbon::today(), Carbon::today()->subDay(3)])->count(); $newOrder = Order::where('status', Order::PENDING)->count(); $newCustomer = Customer::whereIn('created_at', [Carbon::today(), Carbon::today()->subDay(3)])->count(); return view('backend.index')->with(['status' => $status, 'newProduct' => $newProduct, 'newArtist' => $newArtist, 'newOrder' => $newOrder, 'newCustomer' => $newCustomer]); }
public function shoppingCart($type) { $order = \App\Order::where('slug', $type)->firstOrFail(); if (!session()->has('order')) { session(['order' => [$order->slug]]); } else { session()->push('order', $order->slug); } return redirect('order'); }
public function saveOpenOrder(Request $request) { $validator = Validator::make($request->all(), ['tanggal' => 'required|date', 'places' => 'required', 'karyawan_id' => 'required|exists:karyawans,id'], ['tanggal.required' => 'Tanggal tidak boleh kosong.', 'tanggal.date' => 'Input harus tanggal.', 'places.required' => 'Tempat tidak boleh kosong', 'karyawan_id.required' => 'Karyawan tidak boleh kosong.', 'karyawan_id.exists' => 'Karyawan tidak terdaftar.']); if ($validator->fails()) { return redirect()->back()->withErrors($validator)->withInput(); } $data_order_detail = $request->session()->has('data_order') ? $request->session()->get('data_order') : []; if (!count($data_order_detail)) { return redirect()->back()->withErrors(['no_details' => 'Tidak ada produk yang dipesan.'])->withInput(); } # Create Nota $setting = Setting::first(); // Get Last Order $tanggal = $request->get('tanggal'); $lastOrder = Order::where('tanggal', $tanggal)->get()->count(); $nota = $setting->init_kode . "-" . str_replace('-', '', date('dmY', strtotime($tanggal))) . ($lastOrder + 1); // Order $karyawan_id = $request->get('karyawan_id') ? $request->get('karyawan_id') : (Auth::check() ? Auth::user()->karyawan()->id : '1'); $order = $request->only(['tanggal']) + ['nota' => $nota, 'state' => 'On Going', 'karyawan_id' => $karyawan_id]; $order = Order::create($order); // Order Place $places = explode(',', $request->get('places')); $places = Place::whereIn('id', $places)->get(); $orderPlaces = []; foreach ($places as $place) { $placeType = $place->kategori_id; // For Redirect array_push($orderPlaces, ['order_id' => $order->id, 'place_id' => $place->id, 'harga' => $place->harga]); } OrderPlace::insert($orderPlaces); // Order Detail & Order Detail Bahan $produks = Produk::with(['detail' => function ($query) { $query->join('bahans', 'produk_details.bahan_id', '=', 'bahans.id'); }])->whereIn('id', array_keys($data_order_detail))->get(); $orderDetailBahan = []; foreach ($produks as $produk) { $id = $produk->id; // Order Detail $orderDetail = ['order_id' => $order->id, 'produk_id' => $produk->id, 'hpp' => CountHpp($produk), 'harga_jual' => $data_order_detail[$id]['harga'], 'qty' => $data_order_detail[$id]['qty'], 'use_mark_up' => $produk->use_mark_up, 'mark_up' => $produk->mark_up, 'note' => $data_order_detail[$id]['note']]; //echo "<pre>", print_r($orderDetail), "</pre>"; $orderDetail = OrderDetail::create($orderDetail); if ($produk->detail->count()) { // Order Detail Bahan foreach ($produk->detail as $pd) { array_push($orderDetailBahan, ['order_detail_id' => $orderDetail->id, 'bahan_id' => $pd->bahan_id, 'harga' => $pd->harga, 'qty' => $pd->qty, 'satuan' => $pd->satuan]); } } } OrderDetailBahan::insert($orderDetailBahan); $request->session()->forget('data_order'); Artisan::call('bahan:count'); Artisan::call('produk:count'); return redirect('/order?tgl=' . $tanggal . '&type=' . $placeType)->with('succcess', 'Sukses simpan data order.'); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { if (Auth::user()->id != $this->robot_id) { return $this->respondInsufficientPermissions('User not authorized for this request.'); } $orders = Order::where('delivered_at', null)->get(); if (count($orders) == 0) { return $this->respondNotFound('Orders do not exist.'); } return $this->respond(['data' => $this->orderTransformer->transformCollection($orders->all())]); }
/** * Handle the event. * * @param MadeCheckout $event * @return void */ public function handle(MadeCheckout $event) { // $user = $event->user; $checkout = $event->checkout; //dd($checkout); $orders = Order::where('checkout_id', $checkout->id)->get(); foreach ($orders as $order) { Tempcart::where('user_id', $user->id)->where('product_id', $order->product_id)->delete(); } }
/** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { if (Auth::check()) { if (Auth::user()->role == 'admin') { $products = \App\Order_Product::query()->join('product', 'order_product.product_id', '=', 'product.id')->select('order_product.*', 'product.*')->where('order_product.order_id', $id)->get(); $order = \App\Order::where('order_id', $id)->first(); return view('order.edit', compact('products', 'order')); } } else { return view('errors.unauthorized'); } }
public function getSessionOrders() { $id = Session::get('login')['userid']; $orders = Order::where(['UserID' => $id])->get()->toArray(); $fullOrders = []; foreach ($orders as $order) { $orderProducts = Orderdetail::where(['OrderID' => $order['OrderID']])->get(['ProductID', 'Quantity'])->toArray(); $order = array_add($order, 'products', $orderProducts); array_push($fullOrders, $order); } return $fullOrders; }
/** * Handle the event. * * @param MadeCheckout $event * @return void */ public function handle(MadeCheckout $event) { // $user = $event->user; $checkout = $event->checkout; $orders = Order::where('checkout_id', $checkout->id)->get(); $stats = []; foreach ($orders as $order) { array_push($stats, ['user_id' => $user->id, 'product_id' => $order->product_id]); } $sales = DB::table('salesstats')->insert($stats); }