本文整理汇总了PHP中app\Product::getProductById方法的典型用法代码示例。如果您正苦于以下问题:PHP Product::getProductById方法的具体用法?PHP Product::getProductById怎么用?PHP Product::getProductById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Product
的用法示例。
在下文中一共展示了Product::getProductById方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function create($pid)
{
//获取当前用户的信息
$uid = Auth::user()->id;
// dd(Auth::user()->toArray());
$product = Product::getProductById($pid);
$product = $product[0];
$pastid = $pid . time();
//订单随机号
//如果订单没有生成
if (!Past::exsitId($uid, $pid)) {
$past = new Past();
$past->pastid = $pastid;
$past->uid = $uid;
$past->pid = $pid;
$past->pname = $product->name;
$past->price = $product->price;
$past->type = $product->type;
$past->payway = $product->payway;
$past->image = $product->images;
$past->save();
} else {
$past = Past::getPastByUPid($uid, $pid);
$past = $past[0];
$pastid = $past->pastid;
}
// dd($product);
$this->show($pastid);
return redirect('past/show' . "/" . $pastid);
}
示例2: cartConstruct
public function cartConstruct()
{
$cart_id_q = Session::get('cart');
if (!empty($cart_id_q)) {
$product = new Product();
for ($i = 0; $i < count($cart_id_q); $i++) {
$id = key($cart_id_q);
$product_position = ['id' => $id, 'name' => $product->getProductById($id)->name, 'price' => $product->getProductById($id)->price, 'quantity' => $cart_id_q[$id], 'cost' => $product->getProductById($id)->price * $cart_id_q[$id]];
$cart[$id] = $product_position;
next($cart_id_q);
}
return $cart;
} else {
return false;
}
}
示例3: addProduct
public function addProduct($id, $name)
{
$product = Product::getProductById($id);
$quantity = Request::input('quantity');
Cart::add($product[0]->product_id, $name, $quantity, $product[0]->price, ['filename' => $product[0]->filename, 'quantity' => $product[0]->quantity, 'category' => $product[0]->category]);
return Redirect::to('/produkt/' . $id . '/' . $name)->with('message', 'Produkt został dodany do koszyka.');
}
示例4: product
public function product($id)
{
$this->view['title'] .= 'Panel administracyjny - Produkty';
$productView = ['product' => Product::getProductById($id)];
return view('admin/template', $this->view)->nest('content', 'admin/product', $productView);
}