예제 #1
0
 public function create(CreateProductRequest $request)
 {
     //getDataRequest
     $dataRequest = $request->all();
     // validate image
     $files = Input::file('image');
     //check upload
     $upload = new UploadImage();
     if ($upload->upload($files)) {
         $dataRequest['portal'] = $upload->name;
     } else {
         return redirect_errors('Have error , upload image');
     }
     //end check upload
     //rule if  hasn't group price
     $rulesNotGroup = ['root_price' => 'required|min:0', 'price' => 'required|min:0', 'sale_off' => 'required|min:0|max:99'];
     //rules has group
     $rulesGroup = ['group_price_id' => 'required|exists:price_groups,id'];
     $validatorRulesGroup = Validator::make($dataRequest, $rulesGroup);
     $validatorNotRulesGroup = Validator::make($dataRequest, $rulesNotGroup);
     if ($validatorRulesGroup->fails() and $validatorNotRulesGroup->fails()) {
         return redirect_errors('You must fill up form!');
     } else {
         $model = new Cd();
         $model = autoAssignDataToProperty($model, $dataRequest);
         if ($model->save()) {
             return redirect()->back()->with('success', 'Added!');
         } else {
             return redirect_errors('Have error, cannot Add!');
         }
     }
 }
 /**
  * Store a newly created Product in storage.
  *
  * @param CreateProductRequest $request
  *
  * @return Response
  */
 public function store(CreateProductRequest $request)
 {
     $input = $request->all();
     $product = $this->productRepository->create($input);
     Flash::success('Product saved successfully.');
     return redirect(route('products.index'));
 }
예제 #3
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(\App\Http\Requests\CreateProductRequest $request)
 {
     $product = \App\Models\Product::create($request->all());
     $fileName = \Carbon\Carbon::now()->timestamp . "_product.jpg";
     $request->file('photo')->move('img', $fileName);
     $product->photo = $fileName;
     $product->save();
     return redirect('categories/' . $product->category->id);
 }
예제 #4
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(CreateProductRequest $request)
 {
     $data = $request->input();
     $product = new Product($data);
     $product->save();
     $this->savePhoto($product, $request);
     $product->categories()->attach($data['categories']);
     return Redirect()->route('home');
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(\App\Http\Requests\CreateProductRequest $request)
 {
     $product = \App\Models\Product::create($request->all());
     //move file from temp location to productPhtots
     $fileName = \Carbon\Carbon::now()->timestamp . "_photo.jpg";
     $request->file('photo')->move('productphotos', $fileName);
     $product->photo = $fileName;
     $product->save();
     return redirect('types/' . $product->type->id);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(CreateProductRequest $request)
 {
     $user = Auth::user();
     $input = $request->all();
     $file = $input['files'];
     $file_id = $this->addThumbnail($file);
     $input['fileentry_id'] = $file_id;
     $product = Product::create($input);
     $user->products()->save($product, ['owner' => '1']);
     Flash::message('Product saved successfully.');
     return redirect(route('products.show', [$product->id]));
 }
예제 #7
0
 /**
  * Update a product with a POST request
  *
  * @param CreateProductRequest $request
  * @param Product $product
  * @return \Illuminate\Http\RedirectResponse
  */
 public function updateProduct(CreateProductRequest $request, Product $product)
 {
     $product->update($request->except(['_token', 'editorValue']));
     $product->description = $request->input("editorValue");
     return $product->save() ? redirect()->back()->with(['status' => 'success', 'message' => '产品更新成功']) : redirect()->back()->with(['status' => 'error', 'message' => '产品更新失败, 请重试']);
 }
예제 #8
0
 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update(Product $product, CreateProductRequest $request)
 {
     $data = $request->all();
     $data['other_list'] = $this->arrayStr($data['other_list']);
     $data['standard_features'] = $this->arrayStr($data['standard_features']);
     $product->update($data);
     return redirect('products');
 }
 /**
  * @param CreateProductRequest $request
  * @return \Illuminate\Http\Response
  */
 public function store(CreateProductRequest $request)
 {
     $product = $this->productRepo->save($request->input());
     return $this->itemResponse($product);
 }
예제 #10
0
 function update(Product $product, CreateProductRequest $request)
 {
     $product->update($request->all());
     return redirect('products');
 }
예제 #11
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(CreateProductRequest $request)
 {
     $product = Product::create($request->all());
     Session::flash('message', $product->name . ' was registred !');
     return \Redirect::route('products.index');
 }
 /**
  * Update the specified Product in storage.
  *
  * @param  int    $id
  * @param CreateProductRequest $request
  *
  * @return Response
  */
 public function update($id, CreateProductRequest $request)
 {
     /** @var Product $product */
     $product = Product::find($id);
     if (empty($product)) {
         Flash::error('Product not found');
         return redirect(route('admin.products.index'));
     }
     $product->fill($request->all());
     $product->save();
     $this->syncFiles($product, $request->input('files'));
     Flash::message('Product updated successfully.');
     return redirect(route('admin.products.index'));
 }
예제 #13
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  CreateProductRequest  $request
  * @return \Illuminate\Http\Response
  */
 public function store(CreateProductRequest $request)
 {
     $product = Product::create($request->all());
     $this->message->flash("PUNY HUMAN - Your Product has been created!");
     return redirect()->route('backend.products.show', compact('product'));
 }