app/Http/Controllers/Admin/ProductController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(ProductRequest $request, $id)
    {
        $dados =$request->all();
        $product =$this->product->find($id);
        $product->update($dados);
        $product->categories()->sync($dados['categories']);
         $imagens =$request->photos;
        if($request->hasFile('photos'))
        {
          $fotos = $this->uploadImages($imagens,'image');
          $product->photos()->createMany($fotos);
        }
        flash('Produtos atualizados com sucesso!')->success();
        return redirect()->route('admin.products.index');
    }
public function update ( ProductRequest $ request , $ id ) { $ dados = $ request -> all ( ) ; $ product = $ this -> product -> find ( $ id ) ; $ product -> update ( $ dados ) ; $ product -> categories ( ) -> sync ( $ dados [ 'categories' ] ) ; $ imagens = $ request -> photos ; if ( $ request -> hasFile ( 'photos' ) ) { $ fotos = $ this -> uploadImages ( $ imagens , 'image' ) ; $ product -> photos ( ) -> createMany ( $ fotos ) ; } flash ( 'Produtos atualizados com sucesso!' ) -> success ( ) ; return redirect ( ) -> route ( 'admin.products.index' ) ; }
Update the specified resource in storage.
Update the specified resource in storage .