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


PHP Cart::create方法代码示例

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


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

示例1: run

 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Cart::create([]);
     }
 }
开发者ID:yanguanglan,项目名称:sz,代码行数:7,代码来源:CartsTableSeeder.php

示例2: postAddtocart

 public function postAddtocart()
 {
     $product = Product::find(Input::get('id'));
     $quantity = Input::get('quantity');
     $member_id = Auth::user()->id;
     Cart::create(array('product_id' => $product->id, 'name' => $product->title, 'price' => $product->price, 'quantity' => $quantity, 'image' => $product->image, 'member_id' => $member_id));
     return Redirect::to('store/cart');
 }
开发者ID:ayooby,项目名称:laravel4-ecomm,代码行数:8,代码来源:StoreController.php

示例3: store

 /**
  * Store a newly created cart in storage.
  *
  * @return Response
  */
 public function store()
 {
     $validator = Validator::make($data = Input::all(), Cart::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     Cart::create($data);
     return Redirect::route('carts.index');
 }
开发者ID:NocturnalWare,项目名称:managedotband,代码行数:14,代码来源:CartsController.php

示例4: postAddToCart

 public function postAddToCart()
 {
     //validation
     $rules = ['amount' => 'required|numeric', 'book' => 'required|numeric|exists:books,id'];
     //inputs, rules
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::route('index')->with('error', 'The book could not be added to your cart');
     }
     $member_id = Auth::user()->id;
     $book_id = Input::get('book');
     $amount = Input::get('amount');
     $book = Book::find($book_id);
     $total = $amount * $book->price;
     //checking existing in the cart
     $count = Cart::where('book_id', '=', $book_id)->where('member_id', '=', $member_id)->count();
     if ($count) {
         return Redirect::route('index')->with('error', 'The book already exists in your cart.');
     }
     Cart::create(['member_id' => $member_id, 'book_id' => $book_id, 'amount' => $amount, 'total' => $total]);
     return Redirect::route('cart');
 }
开发者ID:ngeshlew,项目名称:laravel-e-commerce-book-store,代码行数:22,代码来源:CartController.php


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