/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $order = Order::findOrFail($id); $deleted = $order->delete(); $message = $deleted ? 'Order Deleted succesfully!' : 'Order It could not be deleted !'; return redirect()->route('admin.order.index')->with('message', $message); }
public function report($id) { $user = User::find($id); $orders = Order::where('user_id', '=', $id)->orderBy('created_at', 'DESC')->get(); return view('admin.users.report', compact('orders', 'user')); }
protected function saveOrder() { $subtotal = 0; $cart = \Session::get('product'); $shipping = 100; $subtotal = 1 * $cart->price; $order = Order::create(['subtotal' => $subtotal, 'shipping' => $shipping, 'user_id' => \Auth::user()->id]); $this->saveOrderItem($cart, $order->id); if (Auth::user()->suscriptor == 1) { $fecha = Carbon::parse(Auth::user()->date_suscripcion)->addMonths($cart->duration); Auth::user()->date_suscripcion = $fecha; Auth::user()->save(); } else { $fecha = Carbon::now()->addMonths($cart->duration); Auth::user()->date_suscripcion = $fecha; Auth::user()->suscriptor = 1; Auth::user()->save(); } Auth::user()->save(); }