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


PHP ShoppingCart::where方法代码示例

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


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

示例1: cart

 /**
  * View: Customer shopping cart
  * @return Response
  */
 public function cart()
 {
     // Get sort conditions
     $orderColumn = Input::get('sort_up', Input::get('sort_down', 'created_at'));
     $direction = Input::get('sort_up') ? 'asc' : 'desc';
     // Get search conditions
     switch (Input::get('target')) {
         case 'title':
             $title = Input::get('like');
             break;
     }
     // Construct query statement
     $query = ShoppingCart::orderBy($orderColumn, $direction)->where('buyer_id', Auth::user()->id)->paginate(15);
     isset($title) and $query->where('title', 'like', "%{$title}%");
     $datas = $query;
     $payment = ShoppingCart::where('buyer_id', Auth::user()->id)->sum('payment');
     $resource = 'myproduct';
     $resourceName = '购物车';
     return View::make($this->resourceView . '.cart')->with(compact('datas', 'resource', 'resourceName', 'payment'));
 }
开发者ID:rimshavbase,项目名称:timefragment,代码行数:24,代码来源:ProductController.php

示例2: payment

 /**
  * Action: Payment after add goods in shopping cart
  * @return Response
  */
 public function payment()
 {
     $resourceName = '订单';
     $resource = 'order';
     // Get all form data.
     $data = Input::all();
     $rules = array('product_id' => 'required|', 'customer_name' => 'required', 'customer_address' => 'required', 'customer_phone' => 'required|numeric');
     // Custom validation message
     $messages = array('customer_name.required' => '请填写收货人姓名', 'customer_address.required' => '请填写收货地址', 'customer_phone.required' => '请填写您的手机号码', 'customer_phone.numeric' => '请填写正确的手机号码');
     // Begin verification
     $validator = Validator::make($data, $rules, $messages);
     // Save user real name
     if (Auth::user()->username == NULL) {
         $user = Auth::user();
         $user->username = Input::get('customer_name');
         $user->save();
     }
     // Save user mobile phone number
     if (Auth::user()->phone == NULL) {
         $user = Auth::user();
         $user->phone = Input::get('customer_phone');
         $user->save();
     }
     $product_id = Input::input('product_id');
     $product = Product::where('id', $product_id)->first();
     $data = ShoppingCart::where('buyer_id', Auth::user()->id)->where('product_id', $product_id)->first();
     if ($product->quantity < $data->quantity) {
         return Redirect::back()->with('error', '商品剩余数量不足');
     } else {
         // Verification Success
         if ($validator->passes()) {
             $order_id = md5(date('his')) . $product_id . Auth::user()->id;
             $seller_id = $data->seller_id;
             $seller_alipay = User::where('id', $seller_id)->first()->alipay;
             $order_name = '时光碎片网购物-' . $product->title;
             $payment = $data->payment;
             $goods_show = 'http://www.timefragment.com/product/' . $product->slug;
             $customer_name = Input::input('customer_name');
             $customer_address = Input::input('customer_address');
             $customer_phone = Input::input('customer_phone');
             // Create product order
             $product_order = $this->model;
             $product_order->order_id = $order_id;
             $product_order->seller_id = $seller_id;
             $product_order->product_id = $product_id;
             $product_order->customer_id = Auth::user()->id;
             $product_order->customer_address = $customer_address;
             $product_order->quantity = $data->quantity;
             $product_order->price = $data->price;
             $product_order->payment = $payment;
             $product_order->save();
             // Destroy goods in shopping cart
             $data->delete();
             // Alipay API
             require_once app_path('api/alipay/alipay.config.php');
             require_once app_path('api/alipay/lib/alipay_submit.class.php');
             // Request parameters
             $payment_type = "1";
             // Payment type (required, don't modify)
             $notify_url = route('order.tradeNotify');
             // Server asynchronous notification page URL (start with http://, don't use http://localhost/ or add ?id=123)
             $return_url = route('order.tradeReturn');
             // Synchronization notification page URL (start with http://, don't use http://localhost/ or add ?id=123)
             $seller_email = $seller_alipay;
             // Saller Alipay ID (required)
             $out_trade_no = $order_id;
             // Order ID (required)
             $subject = $order_name;
             // Order name (required)
             $price = $payment;
             // Order payment (required)
             $quantity = "1";
             // Goods quantity (default is 1)
             $logistics_fee = "0.00";
             // Express payment (required)
             $logistics_type = "EXPRESS";
             // Express type: EXPRESS, POST or EMS
             $logistics_payment = "SELLER_PAY";
             // Express payment type (require:SELLER_PAY customer pay or BUYER_PAY saller pay)
             $body = $goods_show;
             // Order describe
             $show_url = $goods_show;
             // Goods show page (URL start with http://)
             $receive_name = $customer_name;
             // Customer name
             $receive_address = $customer_address;
             // Customer address
             $receive_zip = NULL;
             // Customer zip (code such as:123456)
             $receive_phone = NULL;
             // Custome telephone number (such as:0571-88158090)
             $receive_mobile = $customer_phone;
             // Customer mobile phone numer (such as:13312341234)
             // Constructs an array of arguments to request, no need to change
             $parameter = array("service" => "trade_create_by_buyer", "partner" => trim($alipay_config['partner']), "payment_type" => $payment_type, "notify_url" => $notify_url, "return_url" => $return_url, "seller_email" => $seller_email, "out_trade_no" => $out_trade_no, "subject" => $subject, "price" => $price, "quantity" => $quantity, "logistics_fee" => $logistics_fee, "logistics_type" => $logistics_type, "logistics_payment" => $logistics_payment, "body" => $body, "show_url" => $show_url, "receive_name" => $receive_name, "receive_address" => $receive_address, "receive_zip" => $receive_zip, "receive_phone" => $receive_phone, "receive_mobile" => $receive_mobile, "_input_charset" => trim(strtolower($alipay_config['input_charset'])));
             // Establishing request
//.........这里部分代码省略.........
开发者ID:rimshavbase,项目名称:timefragment,代码行数:101,代码来源:ProductOrderController.php


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