/**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(UpdateFileRequest $request, $id)
 {
     $file = File::find($id);
     if ($file) {
         $file->title = $request->get('title');
         $file->description = $request->get('description');
         if ($request->hasFile('file')) {
             FileManager::delete(public_path() . $file->path);
             $file->path = $this->storeFile($request);
         }
         $file->save();
         return response()->json(['data' => "The file {$file->id} was updated"], 200);
     }
     return response()->json(['message' => 'Does not exist a file with that id'], 404);
 }
示例#2
0
 /**
  * Update the specified File in storage.
  *
  * @param  int              $id
  * @param UpdateFileRequest $request
  *
  * @return Response
  */
 public function update($id, UpdateFileRequest $request)
 {
     $file = $this->fileRepository->find($id);
     if (empty($file)) {
         Flash::error('File not found');
         return redirect(route('files.index'));
     }
     if ($file->update($request->all())) {
         Flash::success('File updated successfully.');
         return redirect(route('files.index'));
     }
 }