Exemplo n.º 1
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(MaterialRequest $request, $id)
 {
     $material = Material::findOrFail($id);
     $data = $request->all();
     if ($material->photo_name != $request->input('photo_name')) {
         $data = $this->add_photo($request);
         \File::delete($material->photo_path);
         \File::delete($material->photo_thumbnail_path);
     }
     $material->update($data);
     return redirect()->route('admin.element.material.index')->withFlashSuccess(trans("element_backend.element_material_update"));
 }