本文整理匯總了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;