本文整理汇总了PHP中app\Product::addProduct方法的典型用法代码示例。如果您正苦于以下问题:PHP Product::addProduct方法的具体用法?PHP Product::addProduct怎么用?PHP Product::addProduct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Product
的用法示例。
在下文中一共展示了Product::addProduct方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return Response
*/
public function store(ProductRequest $request)
{
//
$data = $request->all();
if (isset($data['image'])) {
$thumb = $data['image'];
$new = 'pro' . uniqid() . '.' . $thumb->getClientOriginalExtension();
$thumb->move('upload/product', $new);
}
$data['image'] = $new;
$productId = Product::addProduct($data);
$multi_image = Input::file('multi-images');
foreach ($multi_image as $multi) {
# code...
$thumbnail = 'multi' . uniqid() . '.' . $multi->getClientOriginalExtension();
$multi->move('upload/multi-image', $thumbnail);
Image::addImage($productId, $thumbnail);
}
if (Input::get('color') != "") {
$color = Input::get('color');
foreach ($color as $colorId) {
# code...
MapColor::mapColor($colorId, $productId);
}
}
if ($data['other_color'] != "") {
$other = $data['other_color'];
$colorId = Color::addColor($other);
MapColor::mapColor($colorId, $productId);
}
if (Input::get('size') != "") {
$size = Input::get('size');
foreach ($size as $sizeId) {
# code...
MapSize::mapSize($sizeId, $productId);
}
}
if ($data['other_size'] != "") {
$other = $data['other_size'];
$sizeId = Size::addSize($other);
MapSize::mapsize($sizeId, $productId);
}
return redirect('admin/product');
//return "ok";
}
示例2: addProduct
public function addProduct()
{
$data = ['name' => Request::input('name'), 'description' => Request::input('description'), 'price' => Request::input('price'), 'quantity' => Request::input('quantity'), 'category' => Request::input('add_category'), 'image' => Request::file('cover_image')];
$productId = Product::addProduct($data);
return Redirect::to('/admin/produkt/' . $productId)->with('message', 'Produkt został dodany.');
}