本文整理汇总了PHP中Basket::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Basket::save方法的具体用法?PHP Basket::save怎么用?PHP Basket::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Basket
的用法示例。
在下文中一共展示了Basket::save方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: function
$basket = Basket::where('sessionId', '=', Session::getId())->first();
return View::make('index')->with('ps', $ps)->with('basket', $basket);
});
Route::post('add-to-basket', ['as' => 'add.to.basket', function () {
//$id = Input::get('id');
//$count = Input::get('count', 1);
// create or find old basket
$basket = Basket::where('sessionId', '=', Session::getId())->first();
if (!$basket) {
$basket = new Basket();
$basket->price = 0;
$basket->productCount = 0;
$basket->status = Basket::STATUS_UNPAYED;
$basket->date = date('Y-m-d H:i:s');
$basket->sessionId = Session::getId();
$basket->save();
}
// find prodcudt
$product = Product::find(Input::get('id'));
// add product to pasket products
$bp = new BasketProduct();
$bp->basketId = $basket->id;
$bp->productId = $product->id;
$bp->count = Input::get('count');
$bp->price = $product->price;
$bp->save();
//
$row = DB::table('basket_product')->select(DB::raw('SUM(price) as p'), DB::raw('SUM(count) as c'))->where('basketId', '=', $basket->id)->first();
//
$basket->price = $row->p;
$basket->productCount = $row->c;