当前位置: 首页>>代码示例>>PHP>>正文


PHP Order::ofType方法代码示例

本文整理汇总了PHP中app\Order::ofType方法的典型用法代码示例。如果您正苦于以下问题:PHP Order::ofType方法的具体用法?PHP Order::ofType怎么用?PHP Order::ofType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\Order的用法示例。


在下文中一共展示了Order::ofType方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: index

 public function index()
 {
     $panel = ['center' => ['width' => 10], 'left' => ['width' => 2, 'class' => 'home-no-padding']];
     $helperProd = new productsHelper();
     $carousel = $helperProd->suggest('carousel');
     $viewed = $helperProd->suggest('viewed', 8);
     $categories = $helperProd->suggest('categories');
     $purchased = $helperProd->suggest('purchased');
     $suggestion = ['carousel' => $carousel, 'viewed' => $viewed, 'categories' => $categories, 'purchased' => $purchased];
     $helperProd->resetHaystack();
     //reseting session id validator
     $events = [];
     if (config('app.offering_free_products')) {
         $events = FreeProduct::getNextEvents(['id', 'description', 'min_participants', 'max_participants', 'participation_cost', 'start_date', 'end_date'], 4, date('Y-m-d'));
     }
     $tagsCloud = ProductsController::getTopRated(0, 20, true);
     $allWishes = '';
     $user = \Auth::user();
     if ($user) {
         $allWishes = Order::ofType('wishlist')->where('user_id', $user->id)->where('description', '<>', '')->get();
     }
     $i = 0;
     //carousel implementation
     $jumbotronClasses = ['jumbotron-box-left', 'jumbotron-box-right'];
     //carousel implementation
     $banner = ['/img/banner/01.png', '/img/banner/02.png', '/img/banner/03.png', '/img/banner/04.png'];
     // $this->createTags();
     return view('home', compact('panel', 'suggestion', 'allWishes', 'events', 'tagsCloud', 'jumbotronClasses', 'i', 'banner'));
 }
开发者ID:masterpowers,项目名称:antVel,代码行数:29,代码来源:HomeController.php

示例2: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     try {
         $validator = Validator::make($request->all(), $this->form_rules);
         if ($validator->fails()) {
             return redirect()->route('freeproducts.create', [$request->input('order_id')])->withErrors($validator->errors())->withInput();
         }
         //As is not defined that way is going to deliver products for every winner, I will confirm that the total winning is equal to total products in the cart
         $cart_detail = OrderDetail::where('order_id', $request->input('order_id'))->get();
         if ($request->input('draw_number') > $cart_detail->count()) {
             return redirect()->route('freeproducts.create', [$request->input('order_id')])->withErrors(trans('freeproduct.drawnumber_exceed_total_products'))->withInput();
         } else {
             //Process the order. The process is the same as with a shopping cart. The address is not requested
             //Direction is taken as the one with the user by default. Not having, it notifies the user to create a.
             $errors = Order::placeOrders('freeproduct');
             if ($errors) {
                 return redirect()->route('freeproducts.create', [$request->input('order_id')])->withErrors($errors)->withInput();
             } else {
                 $user = \Auth::user();
                 //Save Free Product
                 $freeproduct = new FreeProduct();
                 $freeproduct->user_id = $user->id;
                 $freeproduct->description = $request->input('description');
                 $freeproduct->start_date = $request->input('start_date');
                 $freeproduct->end_date = $request->input('end_date');
                 $freeproduct->participation_cost = $request->input('participation_cost');
                 $freeproduct->min_participants = $request->input('min_participants');
                 $freeproduct->max_participants = $request->input('max_participants');
                 $freeproduct->max_participations_per_user = $request->input('max_participations_per_user');
                 $freeproduct->draw_number = $request->input('draw_number');
                 $freeproduct->draw_date = $request->input('draw_date');
                 $freeproduct->save();
                 //Because the method placeOrders products generates orders for each vendor, you need to associate these orders to free product
                 $orders = Order::ofType('freeproduct')->ofStatus('paid')->where('user_id', $user->id)->get();
                 if ($orders) {
                     foreach ($orders as $order) {
                         //Each order products are searched and a duplicate of the same is made, marking them as a free product. This will allow the product goes on the results of the advanced search
                         $order_detail = OrderDetail::where('order_id', $order->id)->get();
                         if ($order_detail) {
                             foreach ($order_detail as $detail) {
                                 $product = Product::find($detail->product_id);
                                 $productactual = $product->toArray();
                                 unset($productactual['id']);
                                 unset($productactual['num_of_reviews']);
                                 $productactual['user_id'] = $user->id;
                                 $productactual['stock'] = $detail->quantity;
                                 $productactual['type'] = 'freeproduct';
                                 $productactual['parent_id'] = $product->id;
                                 $newproduct = Product::create($productactual);
                             }
                         }
                         if (!FreeProductOrder::where('order_id', $order->id)->first()) {
                             //order registration as a free product
                             $order_to_fp = new FreeProductOrder();
                             $order_to_fp->freeproduct_id = $freeproduct->id;
                             $order_to_fp->order_id = $order->id;
                             $order_to_fp->save();
                         }
                     }
                 }
                 //Send message process Ok and redirect
                 Session::flash('message', trans('freeproduct.saved_successfully'));
                 return redirect()->route('freeproducts.show', [$freeproduct->id]);
             }
         }
     } catch (ModelNotFoundException $e) {
         Log::error($e);
         return redirect()->back()->withErrors(['induced_error' => [trans('freeproduct.error_exception')]])->withInput();
     }
 }
开发者ID:ant-vel,项目名称:antVel,代码行数:75,代码来源:FreeProductsController.php

示例3: getCartContent

 public function getCartContent()
 {
     $basicCart = Order::ofType('cart')->where('user_id', $this->id)->first();
     if (!$basicCart) {
         return [];
     } else {
         return $basicCart->details;
     }
 }
开发者ID:masterpowers,项目名称:antVel,代码行数:9,代码来源:User.php

示例4: showDetailsProductCart

 /**
  *   get keys registered (Only this seller)
  *   @param  $id         int|string  id product
  *   @param  $request    Request     object to validate the type of request
  *   @return json
  */
 public function showDetailsProductCart($id, Request $request)
 {
     if (!$request->wantsJson()) {
         return json_encode(['message' => trans('globals.error_not_available')]);
     }
     $cart = Order::ofType('cart')->select('id')->where('user_id', \Auth::user()->id)->first();
     if (!$cart) {
         return json_encode(['message' => trans('globals.error_not_available')]);
     }
     $product = Product::find($id);
     if (!$product) {
         return json_encode(['message' => trans('globals.error_not_available')]);
     }
     $order = OrderDetail::where('order_id', $cart->id)->where('product_id', $product->id)->first();
     if (!$order) {
         return json_encode(['message' => trans('globals.error_not_available')]);
     }
     $seller = User::select('nickname')->find($product->user_id);
     $product->seller = $seller->nickname;
     $return = ['product' => $product, 'order' => $order];
     if ($product->type != 'item') {
         $virtual = VirtualProduct::where('product_id', $product->id)->first();
         $arrayV = ['type' => $product->type, 'title' => trans('product.globals.digital_item') . ' ' . trans('product.' . $product->type)];
         switch ($product->type) {
             case 'key':
                 $virtualOrder = VirtualProductOrder::where('virtual_product_id', $virtual->id)->where('order_id', $order->order_id)->where('status', 1)->get();
                 $email = [];
                 foreach ($virtualOrder as $row) {
                     if (isset($email[$row->email])) {
                         $email[$row->email]['num']++;
                     } else {
                         $email[$row->email]['num'] = 1;
                         $email[$row->email]['email'] = $row->email;
                     }
                 }
                 $arrayV['data'] = $email;
                 break;
         }
         $return['virtual'] = $arrayV;
     }
     return json_encode($return);
 }
开发者ID:rolka,项目名称:antVel,代码行数:48,代码来源:OrdersController.php

示例5: show

 /**
  * Display the specified resource.
  *
  * @param int $id
  *
  * @return Response
  */
 public function show($id)
 {
     $user = \Auth::user();
     $allWishes = '';
     $panel = ['center' => ['width' => '12']];
     if ($user) {
         $allWishes = Order::ofType('wishlist')->where('user_id', $user->id)->where('description', '<>', '')->orderBy('id', 'desc')->take(5)->get();
     }
     $product = Product::select(['id', 'category_id', 'user_id', 'name', 'description', 'price', 'stock', 'features', 'condition', 'rate_val', 'rate_count', 'low_stock', 'status', 'type', 'tags', 'products_group', 'brand'])->with(['group' => function ($query) {
         $query->select(['id', 'products_group', 'features']);
     }])->with('categories')->find($id);
     if ($product) {
         //if there is a user in session, the admin menu will be shown
         if ($user && $user->id == $product->user_id) {
             $panel = ['left' => ['width' => '2'], 'center' => ['width' => '10']];
         }
         //retrieving products features
         $features = ProductDetail::all()->toArray();
         //increasing product counters, in order to have a suggestion orden
         $this->setCounters($product, ['view_counts' => trans('globals.product_value_counters.view')], 'viewed');
         //saving the product tags into users preferences
         if (trim($product->tags) != '') {
             UserController::setPreferences('product_viewed', explode(',', $product->tags));
         }
         //receiving products user reviews & comments
         $reviews = OrderDetail::where('product_id', $product->id)->whereNotNull('rate_comment')->select('rate', 'rate_comment', 'updated_at')->orderBy('updated_at', 'desc')->take(5)->get();
         //If it is a free product, we got to retrieve its package information
         if ($product->type == 'freeproduct') {
             $order = OrderDetail::where('product_id', $product->id)->first();
             $freeproduct = FreeProductOrder::where('order_id', $order->order_id)->first();
         }
         $freeproductId = isset($freeproduct) ? $freeproduct->freeproduct_id : 0;
         //products suggestions control
         //saving product id into suggest-listed, in order to exclude products from suggestions type "view"
         Session::push('suggest-listed', $product->id);
         $suggestions = $this->getSuggestions(['preferences_key' => $product->id, 'limit' => 4]);
         Session::forget('suggest-listed');
         //retrieving products groups of the product shown
         if (count($product->group)) {
             $featuresHelper = new featuresHelper();
             $product->group = $featuresHelper->group($product->group);
         }
         return view('products.detailProd', compact('product', 'panel', 'allWishes', 'reviews', 'freeproductId', 'features', 'suggestions'));
     } else {
         return redirect(route('products'));
     }
 }
开发者ID:softsolution,项目名称:antVel,代码行数:54,代码来源:ProductsController.php

示例6: editKey

 /**
  *	edit the number of key registered for email.
  *
  *	@param 	string|int 	id product
  *	@param 	Request 	object to validate the type of request|action to ejecute
  *
  *	@return json
  */
 public function editKey($id, Request $request)
 {
     if (!$request->wantsJson()) {
         return ['message' => trans('globals.error_not_available')];
     }
     if (!$request->has('email')) {
         return ['message' => trans('globals.error_not_available')];
     }
     $cart = Order::ofType('cart')->select('id', 'status')->where('user_id', \Auth::id())->first();
     if (!$cart) {
         return ['message' => trans('globals.error_not_available')];
     }
     $product = Product::select('id', 'stock')->find($id);
     if (!$product) {
         return ['message' => trans('globals.error_not_available')];
     }
     $order = OrderDetail::where('order_id', $cart->id)->where('product_id', $product->id)->first();
     if (!$order) {
         return ['message' => trans('globals.error_not_available')];
     }
     $virtual = VirtualProduct::select('id')->where('product_id', $product->id)->first();
     if ($request->has('delete')) {
         $virtualOrder = VirtualProductOrder::where('virtual_product_id', $virtual->id)->where('email', $request->input('email'))->delete();
         $num2 = VirtualProductOrder::where('virtual_product_id', $virtual->id)->where('status', 1)->get()->toArray();
         if (!count($num2)) {
             $order->delete();
         } else {
             $order->quantity = count($num2);
             $order->save();
         }
         return ['all' => true];
     } elseif ($request->has('decrement')) {
         $virtualOrder = VirtualProductOrder::where('virtual_product_id', $virtual->id)->where('email', $request->input('email'))->where('status', 1)->first();
         $virtualOrder->delete();
         $num2 = VirtualProductOrder::where('virtual_product_id', $virtual->id)->where('status', 1)->get()->toArray();
         if (!count($num2)) {
             $order->delete();
         } else {
             $order->quantity = count($num2);
             $order->save();
         }
         $num = VirtualProductOrder::where('virtual_product_id', $virtual->id)->where('email', $request->input('email'))->where('status', 1)->get()->toArray();
         if (count($num)) {
             return ['delete' => true, 'num' => count($num)];
         }
         return ['all' => true];
     } elseif ($request->has('increment')) {
         $num2 = VirtualProductOrder::where('virtual_product_id', $virtual->id)->where('status', 1)->get()->toArray();
         if (count($num2) + 1 > $product->stock) {
             return ['message' => trans('product.virtualProductOrdersController_controller.no_stock')];
         }
         $virtualOrder = new VirtualProductOrder();
         $virtualOrder->order_id = $order->order_id;
         $virtualOrder->status = 1;
         $virtualOrder->email = $request->input('email');
         $virtualOrder->virtual_product_id = $virtual->id;
         $virtualOrder->save();
         $order->quantity = count($num2) + 1;
         $order->save();
         $num = VirtualProductOrder::where('virtual_product_id', $virtual->id)->where('email', $request->input('email'))->where('status', 1)->get()->toArray();
         return ['insert' => true, 'num' => count($num)];
     }
     return ['message' => trans('globals.error_not_available')];
 }
开发者ID:softsolution,项目名称:antVel,代码行数:72,代码来源:VirtualProductOrdersController.php

示例7: placeOrders

 /**
  * Start the checkout process for any type of order
  *
  * @param  int  $type_order Type of order to be processed
  * @return Response
  */
 public static function placeOrders($type_order)
 {
     $cart = Order::ofType($type_order)->auth()->whereStatus('open')->orderBy('id', 'desc')->first();
     $show_order_route = $type_order == 'freeproduct' ? 'freeproducts.show' : 'orders.show_cart';
     $cartDetail = OrderDetail::where('order_id', $cart->id)->get();
     $address_id = 0;
     //When address is invalid, it is because it comes from the creation of a free product. You must have a user direction (Default)
     if (is_null($cart->address_id)) {
         $useraddress = UserAddress::auth()->orderBy('default', 'DESC')->first();
         if ($useraddress) {
             $address_id = $useraddress->address_id;
         } else {
             return trans('address.no_registered');
         }
     } else {
         $address_id = $cart->address_id;
     }
     $address = Address::where('id', $address_id)->first();
     //Checks if the user has points for the cart price and the store has stock
     //and set the order prices to the current ones if different
     //Creates the lists or sellers to send mail to
     $total_points = 0;
     $seller_email = array();
     foreach ($cartDetail as $orderDetail) {
         $product = Product::find($orderDetail->product_id);
         $seller = User::find($product->user_id);
         if (!in_array($seller->email, $seller_email)) {
             $seller_email[] = $seller->email;
         }
         $total_points += $orderDetail->quantity * $product->price;
         if ($orderDetail->price != $product->price) {
             $orderDetail->price = $product->price;
             $orderDetail->save();
         }
         if ($product->type != 'item') {
             $virtual = VirtualProduct::where('product_id', $orderDetail->product_id)->get();
             $first = $virtual->first();
             //$first=null;
             //foreach ($virtual as $row){
             //$first=$row;
             //break;
             //}
             switch ($product->type) {
                 case 'key':
                 case 'software_key':
                     $virtualOrder = VirtualProductOrder::where('virtual_product_id', $first->id)->where('order_id', $orderDetail->order_id)->where('status', 1)->get();
                     if (count($virtual) - 1 < count($virtualOrder)) {
                         return trans('store.insufficientStock');
                     }
                     break;
                 default:
                     break;
             }
         } elseif ($product->stock < $orderDetail->quantity) {
             return trans('store.insufficientStock');
         }
     }
     //Checks if the user has points for the cart price
     $user = \Auth::user();
     if ($user->current_points < $total_points && config('app.payment_method') == 'Points') {
         return trans('store.cart_view.insufficient_funds');
     }
     if (config('app.payment_method') == 'Points') {
         $negativeTotal = -1 * $total_points;
         //7 is the action type id for order checkout
         $pointsModified = $user->modifyPoints($negativeTotal, 7, $cart->id);
     } else {
         $pointsModified = true;
     }
     if ($pointsModified) {
         //Separate the order for each seller
         //Looks for all the different sellers in the cart
         $sellers = [];
         foreach ($cartDetail as $orderDetail) {
             if (!in_array($orderDetail->product->user_id, $sellers)) {
                 $sellers[] = $orderDetail->product->user_id;
             }
         }
         foreach ($sellers as $seller) {
             //Creates a new order and address for each seller
             $newOrder = new Order();
             $newOrder->user_id = $user->id;
             $newOrder->address_id = $address->id;
             $newOrder->status = $type_order == 'freeproduct' ? 'paid' : 'open';
             $newOrder->type = $type_order == 'freeproduct' ? 'freeproduct' : 'order';
             $newOrder->seller_id = $seller;
             $newOrder->save();
             $newOrder->sendNotice();
             //moves the details to the new orders
             foreach ($cartDetail as $orderDetail) {
                 if ($orderDetail->product->user_id == $seller) {
                     $orderDetail->order_id = $newOrder->id;
                     $orderDetail->save();
                 }
//.........这里部分代码省略.........
开发者ID:WebtoolsWendland,项目名称:antVel,代码行数:101,代码来源:Order.php

示例8: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $user = \Auth::user();
     $allWishes = '';
     $panel = array('center' => ['width' => '12']);
     if ($user) {
         $allWishes = Order::ofType('wishlist')->where('user_id', $user->id)->where('description', '<>', '')->orderBy('id', 'desc')->take(5)->get();
     }
     $product = Product::select('id', 'category_id', 'user_id', 'name', 'description', 'price', 'stock', 'features', 'condition', 'rate_val', 'rate_count', 'low_stock', 'status', 'type', 'tags', 'products_group', 'brand')->with(['group' => function ($query) {
         $query->select('id', 'products_group', 'features');
     }])->find($id);
     if ($product) {
         if ($user && $user->id == $product->user_id) {
             $panel = array('left' => ['width' => '2'], 'center' => ['width' => '10']);
         }
         $features = ProductDetail::all()->toArray();
         //Increasing product counters.
         $this->setCounters($product, ['view_counts' => trans('globals.product_value_counters.view')], 'viewed');
         //saving tags in users preferences
         if (trim($product->tags) != '') {
             UserController::setPreferences('product_viewed', explode(',', $product->tags));
         }
         $details = OrderDetail::where('product_id', $product->id)->whereNotNull('rate_comment')->select('rate', 'rate_comment', 'updated_at')->orderBy('updated_at', 'desc')->take(5)->get();
         $jsonDetails = json_encode($details->toArray());
         //Si es un producto de tipo free, debemos buscar a que paquete freeproduct pertenece
         if ($product->type == 'freeproduct') {
             $order = OrderDetail::where('product_id', $product->id)->first();
             $freeproduct = FreeProductOrder::where('order_id', $order->order_id)->first();
         }
         $freeproductId = isset($freeproduct) ? $freeproduct->freeproduct_id : 0;
         Session::push('suggest-listed', $product->id);
         $suggestions = $this->getSuggestions(['preferences_key' => $product->id, 'limit' => 4]);
         Session::forget('suggest-listed');
         if (count($product->group)) {
             $featuresHelper = new featuresHelper();
             $product->group = $featuresHelper->group($product->group);
         }
         return view('products.show', compact('product', 'panel', 'allWishes', 'jsonDetails', 'freeproductId', 'features', 'suggestions'));
     } else {
         return redirect(route('products'));
     }
 }
开发者ID:rolka,项目名称:antVel,代码行数:48,代码来源:ProductsController.php


注:本文中的app\Order::ofType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。