public function store(ProductCreateRequest $request) { $input = $request->except('categories'); $input = $this->uploadPicture($input); $product = Product::create($input); $product->categories()->attach($request->categories); return redirect('admin/products'); }
public function store(ProductCreateRequest $request) { $product = $this->product->create($request->all()); $product->productLogs()->create(array('user_id' => 1, 'status_log' => 'test b test', 'body' => 'test test test test test')); if ($product) { flash()->success(trans('product.products'), trans('product.product_create_success')); return redirect('/products/' . $product->id); } }
public function store(ProductCreateRequest $request) { $data = $request->all(); if ($request->file('file') != null) { $data = $this->makePic($request->file('file'), $data); } Product::create($data); flash()->success(trans('product.label.name'), trans('product.message_alert.create_success')); return redirect('/products'); }
public function store(ProductCreateRequest $request) { $product = new Product(array('name' => $request->get('name'), 'sku' => $request->get('sku'), 'price' => $request->get('price'), 'description' => $request->get('description'), 'is_downloadable' => $request->get('is_downloadable'), 'authorId' => Auth::user()->id)); $product->save(); // Process the uploaded image $imageName = $product->sku . '.' . $request->file('image')->getClientOriginalExtension(); $request->file('image')->move(base_path() . '/public/imgs/products/', $imageName); return \Redirect::route('products.index')->with('message', 'The product has been added!'); }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update(ProductCreateRequest $request, $id) { $product = Product::findOrFail($id); $product->update(['name' => $request->get('name'), 'sku' => $request->get('sku'), 'price' => $request->get('price'), 'description' => $request->get('description'), 'is_downloadable' => $request->get('is_downloadable')]); return \Redirect::route('admin.products.edit', array($product->id))->with('message', 'The product has been updated!'); }
/** * Store a newly created resource in storage. * * @return Response */ public function store(ProductCreateRequest $request) { $name = $request->Input('name'); $category_id = $request->Input('category_id'); $brand_id = $request->Input('brand_id'); $origin_id = $request->Input('origin_id'); $qty_inventory = $request->Input('qty_inventory'); $price = $request->Input('price'); $content = $request->Input('content'); $discount = $request->Input('discount'); //Check fileImage if ($request->hasFile('image')) { $image = $request->file('image'); $imagename = time() . '-' . $image->getClientOriginalName(); $image->move(public_path() . '/image', $imagename); } else { $imagename = null; } //Status if ($request->Input('status_product') == false) { $status_product = 0; } else { $status_product = 1; } $data = ['name' => $name, 'category_id' => $category_id, 'brand_id' => $brand_id, 'origin_id' => $origin_id, 'qty_inventory' => $qty_inventory, 'price' => $price, 'content' => $content, 'discount' => $discount, 'image' => $imagename, 'status_product' => $status_product]; //dd($data); Product::create($data); //dd($data); //$category = Category::find($category_id);//dong loai SP. // $category->product()->create($data); //store database. return redirect()->route('product.index'); }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update(ProductCreateRequest $request, $id) { $product = Product::findOrFail($id); $product->update(['name' => $request->get('name'), 'sku' => $request->get('sku'), 'price' => $request->get('price'), 'description' => $request->get('description'), 'is_downloadable' => $request->get('is_downloadable')]); $imageName = $product->sku . '.' . $request->file('image')->getClientOriginalExtension(); $request->file('image')->move(base_path() . '/public/imgs/products/', $imageName); return \Redirect::route('admin.products.edit', array($product->id))->with('message', 'The product has been updated!'); }