Ejemplo n.º 1
0
 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update($id, Request $request)
 {
     $productModel = Products::findOrFail($id);
     if (isset($request['attach_file']) && $request['attach_file']) {
         $attachmentFields = $this->attachFileValidator($request);
         $productModel->attachments()->save(new \App\Models\Attachments($attachmentFields));
         return Redirect::back()->withInput($request->except(["attached_file"]));
     }
     if (isset($request['add_Product_Focus_Sub_type']) && $request['add_Product_Focus_Sub_type']) {
         $producFocusSubTypeField = $this->addProducFocusSubTypeValidator($request);
         $productModel->focusSubType()->save(ProductFocusSubType::findOrNew($producFocusSubTypeField["id_Product_Focus_Sub_Type"]));
         return Redirect::back()->withInput($request->except(["add_Product_Focus_Sub_type"]));
     }
     if (isset($request['add_competitor']) && $request['add_competitor']) {
         $competitorProductField = $this->addCompetitorProductValidator($request);
         $productModel->competitor()->save(Products::findOrNew($competitorProductField['id_Competitor_Product']));
         return Redirect::back()->withInput($request->except(["add_competitor"]));
     }
     $productsFields = $this->productValidator($request);
     $productModel->fill($productsFields)->save();
     $this->storeRelatedData($request, $productModel);
     return redirect(route('admin.products.index'))->with('flash', 'The Product was updated');
 }
Ejemplo n.º 2
0
 public function productFocusSubType($focusType)
 {
     return ProductFocusSubType::where("id_Product_Focus_Type", "=", $focusType)->get(["id_Product_Focus_Sub_Type", "Product_Focus_Sub_Type"])->toJson();
 }